mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-08 18:44:30 +00:00
Merge remote-tracking branch 'upstream/master' into 20150306-elastic-indexer
Conflicts: bin/console bower.json composer.json composer.lock lib/Alchemy/Phrasea/Application.php lib/Alchemy/Phrasea/Border/Manager.php lib/Alchemy/Phrasea/Controller/Api/V1.php lib/Alchemy/Phrasea/Core/PhraseaEvents.php lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php lib/classes/caption/field.php lib/classes/record/Interface.php templates/web/prod/index.html.twig www/skins/prod/000000/prodcolor.css
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -234,6 +234,7 @@ class module_report
|
||||
*
|
||||
*/
|
||||
protected $cor_query = [];
|
||||
protected $dateField = 'log.date';
|
||||
protected $isInformative;
|
||||
|
||||
/**
|
||||
@@ -579,6 +580,7 @@ class module_report
|
||||
return new module_report_sqlconnexion($this->app, $this);
|
||||
break;
|
||||
case 'download' :
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
|
||||
return new module_report_sqldownload($this->app, $this);
|
||||
break;
|
||||
case 'question' :
|
||||
@@ -778,7 +780,6 @@ class module_report
|
||||
*/
|
||||
protected function setConfigColumn($tab)
|
||||
{
|
||||
|
||||
foreach ($tab as $column => $row) {
|
||||
foreach ($row as $ind => $value) {
|
||||
$title_text = "";
|
||||
@@ -805,6 +806,18 @@ class module_report
|
||||
}
|
||||
}
|
||||
|
||||
public function setDateField($dateField)
|
||||
{
|
||||
$this->dateField = $dateField;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateField()
|
||||
{
|
||||
return $this->dateField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the final formated array which contains all the result,
|
||||
* we construct the html code from this array
|
||||
@@ -817,6 +830,8 @@ class module_report
|
||||
*/
|
||||
public function buildReport($tab = false, $groupby = false, $on = false)
|
||||
{
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
|
||||
|
||||
if (sizeof($this->report) > 0) {
|
||||
return $this->report;
|
||||
}
|
||||
@@ -824,8 +839,12 @@ class module_report
|
||||
$databox = $this->app['phraseanet.appbox']->get_databox($this->sbas_id);
|
||||
$conn = $databox->get_connection();
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
|
||||
|
||||
$this->buildReq($groupby, $on);
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\nreq=%s\n\n", __FILE__, __LINE__, $this->req), FILE_APPEND);
|
||||
|
||||
try {
|
||||
try {
|
||||
$stmt = $conn->prepare($this->req);
|
||||
@@ -833,24 +852,31 @@ class module_report
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
} catch (DBALException $e) {
|
||||
echo $e->getMessage();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s) %s\n\n", __FILE__, __LINE__, get_class($this)), FILE_APPEND);
|
||||
|
||||
//set request field
|
||||
$this->setChamp($rs);
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
|
||||
//set display
|
||||
$this->setDisplay($tab, $groupby);
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
|
||||
//construct results
|
||||
$this->buildResult($this->app, $rs);
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
|
||||
//calculate prev and next page
|
||||
$this->calculatePages();
|
||||
//do we display navigator ?
|
||||
$this->setDisplayNav();
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
|
||||
//assign all variables
|
||||
$this->setReport();
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
|
||||
|
||||
return $this->report;
|
||||
} catch (\Exception $e) {
|
||||
echo $e->getMessage();
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -43,7 +43,8 @@ class module_report_activity extends module_report
|
||||
|
||||
public function __construct(Application $app, $arg1, $arg2, $sbas_id, $collist)
|
||||
{
|
||||
parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
|
||||
// parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
|
||||
parent::__construct($app, $arg1, $arg2, $sbas_id, "");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,6 +85,7 @@ class module_report_activity extends module_report
|
||||
return $hours;
|
||||
}
|
||||
|
||||
// ==================== Site activity : Site activity =====================
|
||||
/**
|
||||
* @desc get the site activity per hours
|
||||
* @return array
|
||||
@@ -99,15 +101,12 @@ class module_report_activity extends module_report
|
||||
$params = array_merge([], $filter['params']);
|
||||
|
||||
$sql = "
|
||||
SELECT tt.heures, SUM(1) AS nb
|
||||
FROM (
|
||||
SELECT DISTINCT(log.id), DATE_FORMAT( log.date, '%k' ) AS heures
|
||||
SELECT CAST(DATE_FORMAT(log.date, '%k') AS UNSIGNED) AS heures, COUNT(id) AS nb
|
||||
FROM log FORCE INDEX (date_site)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE (" . $filter['sql'] . ")
|
||||
) AS tt
|
||||
GROUP BY tt.heures
|
||||
ORDER BY tt.heures ASC";
|
||||
WHERE (" . $filter['sql'] . ") AND !ISNULL(usrid)
|
||||
GROUP BY heures;";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $sqlBuilder->getConnBas()->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
@@ -196,6 +195,7 @@ class module_report_activity extends module_report
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
// ================== Site activity : Top questions (le second radio ...) ================
|
||||
/**
|
||||
* get the most asked question
|
||||
* @param array $tab config for html table
|
||||
@@ -206,6 +206,7 @@ class module_report_activity extends module_report
|
||||
$this->report['value'] = [];
|
||||
$this->report['value2'] = [];
|
||||
|
||||
$this->setDateField('log_search.date');
|
||||
$sqlBuilder = new module_report_sql($this->app, $this);
|
||||
$filter = $sqlBuilder->getFilters()->getReportFilter();
|
||||
$params = array_merge([], $filter['params']);
|
||||
@@ -213,19 +214,18 @@ class module_report_activity extends module_report
|
||||
($no_answer) ? $this->title = $this->app->trans('report:: questions sans reponses') : $this->title = $this->app->trans('report:: questions les plus posees');
|
||||
|
||||
$sql = "
|
||||
SELECT TRIM(tt.search) AS search, SUM(1) AS nb, ROUND(avg(tt.results)) AS nb_rep
|
||||
FROM (
|
||||
SELECT DISTINCT(log.id), log_search.search AS search, results
|
||||
SELECT TRIM(log_search.search) AS search, COUNT(log_search.id) AS nb, ROUND(avg(results)) AS nb_rep
|
||||
FROM (log_search)
|
||||
INNER JOIN log FORCE INDEX (date_site) ON (log_search.log_id = log.id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE (" . $filter['sql'] . ")
|
||||
WHERE (" . $filter['sql'] . ") AND !ISNULL(usrid)
|
||||
AND log_search.search != 'all' " .
|
||||
($no_answer ? ' AND log_search.results = 0 ' : '') . "
|
||||
) AS tt
|
||||
GROUP BY tt.search
|
||||
($no_answer ? ' AND log_search.results = 0 ' : '') . "
|
||||
|
||||
GROUP BY search
|
||||
ORDER BY nb DESC";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$sql .= !$no_answer ? ' LIMIT ' . $this->nb_top : '';
|
||||
|
||||
$stmt = $sqlBuilder->getConnBas()->prepare($sql);
|
||||
@@ -260,12 +260,14 @@ class module_report_activity extends module_report
|
||||
return $this->report;
|
||||
}
|
||||
|
||||
// =========================== not called ? =====================
|
||||
/**
|
||||
* @desc get all downloads from one specific user
|
||||
* @param $usr user id
|
||||
* @param array $config config for the html table
|
||||
* @return array
|
||||
*/
|
||||
/*
|
||||
public function getAllDownloadByUserBase($usr, $config = false)
|
||||
{
|
||||
$result = [];
|
||||
@@ -319,7 +321,9 @@ class module_report_activity extends module_report
|
||||
|
||||
return $this->result;
|
||||
}
|
||||
*/
|
||||
|
||||
// ============================ Downloads : Daily ==========================
|
||||
/**
|
||||
* @desc get all download by base by day
|
||||
* @param array $tab config for html table
|
||||
@@ -328,28 +332,27 @@ class module_report_activity extends module_report
|
||||
public function getDownloadByBaseByDay($tab = false)
|
||||
{
|
||||
$this->title = $this->app->trans('report:: telechargements par jour');
|
||||
|
||||
$this->setDateField('log_docs.date');
|
||||
$sqlBuilder = new module_report_sql($this->app, $this);
|
||||
$filter = $sqlBuilder->getFilters()->getReportFilter();
|
||||
$params = array_merge([], $filter['params']);
|
||||
|
||||
$sql = "
|
||||
SELECT tt.record_id, DATE_FORMAT(tt.the_date, GET_FORMAT(DATE, 'INTERNAL')) AS ddate, tt.final, SUM(1) AS nb
|
||||
SELECT tt.record_id, tt.the_date AS ddate, tt.final, SUM(1) AS nb
|
||||
FROM (
|
||||
SELECT DISTINCT(log.id), log_docs.date AS the_date, log_docs.final, log_docs.record_id
|
||||
FROM (log_docs)
|
||||
INNER JOIN record ON (record.record_id = log_docs.record_id)
|
||||
INNER JOIN log FORCE INDEX (date_site) ON (log.id = log_docs.log_id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE (" . $filter['sql'] . ")
|
||||
LEFT JOIN record ON (log_docs.record_id = record.record_id)
|
||||
WHERE (" . $filter['sql'] . ") AND !ISNULL(usrid)
|
||||
AND (log_docs.action = 'download' OR log_docs.action = 'mail')
|
||||
AND (log_docs.final = 'preview' OR log_docs.final = 'document')
|
||||
) AS tt
|
||||
LEFT JOIN subdef AS s ON (s.record_id = tt.record_id)
|
||||
WHERE s.name = tt.final
|
||||
GROUP BY tt.final, ddate
|
||||
ORDER BY tt.the_date DESC";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $sqlBuilder->getConnBas()->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
@@ -397,6 +400,17 @@ class module_report_activity extends module_report
|
||||
$this->result[$nb_row]['preview'] = '<b>' . $total['tot_prev'] . '</b>';
|
||||
$this->result[$nb_row]['total'] = '<b>' . $total['tot_dl'] . '</b>';
|
||||
}
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, var_export($this->result, true)), FILE_APPEND);
|
||||
foreach($this->result as $k=>$row) {
|
||||
$_row = array();
|
||||
foreach((array) $tab as $k2=>$f) {
|
||||
$_row[$k2] = array_key_exists($k2, $row) ? $row[$k2] : '';
|
||||
}
|
||||
$this->result[$k] = $_row;
|
||||
}
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, var_export($this->result, true)), FILE_APPEND);
|
||||
|
||||
$this->calculatePages();
|
||||
$this->setDisplayNav();
|
||||
$this->setReport();
|
||||
@@ -404,6 +418,7 @@ class module_report_activity extends module_report
|
||||
return $this->report;
|
||||
}
|
||||
|
||||
// ==================== Connections: Per users =====================
|
||||
/**
|
||||
* @desc get nb connexion by user , fonction ,societe etc..
|
||||
* @param array $tab config for html table
|
||||
@@ -422,25 +437,21 @@ class module_report_activity extends module_report
|
||||
$params = array_merge([], $filter['params']);
|
||||
|
||||
$this->req = "
|
||||
SELECT SUM(1) AS connexion, tt.user, tt.usrid FROM (
|
||||
SELECT
|
||||
DISTINCT(log.id),
|
||||
log." . $on . " AS " . $on . ",
|
||||
log.usrid
|
||||
SELECT COUNT(id) AS connexion, log.user, log.usrid
|
||||
FROM log FORCE INDEX (date_site)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE log.user != 'API'
|
||||
AND (" . $filter['sql'] . ")
|
||||
) AS tt
|
||||
GROUP BY tt.usrid
|
||||
AND (" . $filter['sql'] . ") AND !ISNULL(usrid)
|
||||
GROUP BY usrid
|
||||
ORDER BY connexion DESC ";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $this->req), FILE_APPEND);
|
||||
|
||||
$stmt = $sqlBuilder->getConnBas()->prepare($this->req);
|
||||
$stmt->execute($params);
|
||||
$sqlBuilder->setTotalrows($stmt->rowCount());
|
||||
$stmt->closeCursor();
|
||||
|
||||
$this->enable_limit ? $this->req .= "LIMIT 0," . $this->nb_record : "";
|
||||
$this->enable_limit ? $this->req .= " LIMIT 0," . $this->nb_record : "";
|
||||
|
||||
$stmt = $sqlBuilder->getConnBas()->prepare($this->req);
|
||||
$stmt->execute($params);
|
||||
@@ -490,8 +501,9 @@ class module_report_activity extends module_report
|
||||
return $this->report;
|
||||
}
|
||||
|
||||
// ========================= Downloads : Per users =====================
|
||||
/**
|
||||
* Get the deail of download by users
|
||||
* Get the detail of download by users
|
||||
*
|
||||
* @param array $tab config for the html table
|
||||
* @param String $on
|
||||
@@ -505,25 +517,22 @@ class module_report_activity extends module_report
|
||||
//set title
|
||||
$this->title = $this->app->trans('report:: Detail des telechargements');
|
||||
|
||||
$this->setDateField('log_docs.date');
|
||||
$sqlBuilder = new module_report_sql($this->app, $this);
|
||||
$filter = $sqlBuilder->getFilters()->getReportFilter();
|
||||
$params = array_merge([], $filter['params']);
|
||||
|
||||
$sql = "
|
||||
SELECT tt.usrid, TRIM(" . $on . ") AS " . $on . ", tt.final, sum(1) AS nb, sum(size) AS poid
|
||||
FROM (
|
||||
SELECT DISTINCT(log.id), TRIM(" . $on . ") AS " . $on . ", log_docs.record_id, log_docs.final, log.usrid
|
||||
SELECT TRIM(" . $on . ") AS " . $on . ", SUM(1) AS nb, log_docs.final, log.usrid
|
||||
FROM log_docs
|
||||
INNER JOIN log FORCE INDEX (date_site) ON (log.id = log_docs.log_id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
INNER JOIN record ON (record.record_id = log_docs.record_id)
|
||||
WHERE (" . $filter['sql'] . ")
|
||||
LEFT JOIN record ON (record.record_id = log_docs.record_id)
|
||||
WHERE (" . $filter['sql'] . ") AND !ISNULL(usrid)
|
||||
AND (log_docs.action = 'download' OR log_docs.action = 'mail')
|
||||
) AS tt
|
||||
LEFT JOIN subdef FORCE INDEX (unicite) ON (tt.record_id = subdef.record_id)
|
||||
WHERE subdef.name = tt.final
|
||||
GROUP BY " . $on . ", usrid
|
||||
ORDER BY nb DESC;";
|
||||
AND (log_docs.final = 'preview' OR log_docs.final = 'document')
|
||||
GROUP BY usrid";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $sqlBuilder->getConnBas()->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
@@ -534,9 +543,7 @@ class module_report_activity extends module_report
|
||||
$i = -1;
|
||||
$total = [
|
||||
'nbdoc' => 0,
|
||||
'poiddoc' => 0,
|
||||
'nbprev' => 0,
|
||||
'poidprev' => 0
|
||||
];
|
||||
|
||||
$this->setChamp($rs);
|
||||
@@ -547,47 +554,36 @@ class module_report_activity extends module_report
|
||||
$user = $row[$on];
|
||||
if (($save_user != $user) && ! is_null($user) && ! empty($user)) {
|
||||
if ($i >= 0) {
|
||||
if (($this->result[$i]['nbprev'] + $this->result[$i]['nbdoc']) == 0 || ($this->result[$i]['poiddoc'] + $this->result[$i]['poidprev']) == 0) {
|
||||
if (($this->result[$i]['nbprev'] + $this->result[$i]['nbdoc']) == 0) {
|
||||
unset($this->result[$i]);
|
||||
}
|
||||
|
||||
if (isset($this->result[$i]['poiddoc']) && isset($this->result[$i]['poidprev'])) {
|
||||
$this->result[$i]['poiddoc'] = p4string::format_octets($this->result[$i]['poiddoc']);
|
||||
$this->result[$i]['poidprev'] = p4string::format_octets($this->result[$i]['poidprev']);
|
||||
}
|
||||
}
|
||||
|
||||
$i ++;
|
||||
|
||||
$this->result[$i]['nbprev'] = 0;
|
||||
$this->result[$i]['poidprev'] = 0;
|
||||
$this->result[$i]['nbdoc'] = 0;
|
||||
$this->result[$i]['poiddoc'] = 0;
|
||||
}
|
||||
|
||||
//doc info
|
||||
if ($row['final'] == 'document' &&
|
||||
! is_null($user) && ! is_null($row['usrid'])) {
|
||||
$this->result[$i]['nbdoc'] = ( ! is_null($row['nb']) ? $row['nb'] : 0);
|
||||
$this->result[$i]['poiddoc'] = ( ! is_null($row['poid']) ? $row['poid'] : 0);
|
||||
$this->result[$i]['user'] = empty($row[$on]) ?
|
||||
"<i>" . $this->app->trans('report:: non-renseigne') . "</i>" : $row[$on];
|
||||
$total['nbdoc'] += $this->result[$i]['nbdoc'];
|
||||
$total['poiddoc'] += ( ! is_null($row['poid']) ? $row['poid'] : 0);
|
||||
$this->result[$i]['usrid'] = $row['usrid'];
|
||||
}
|
||||
//preview info
|
||||
if (($row['final'] == 'preview' || $row['final'] == 'thumbnail') &&
|
||||
if (($row['final'] == 'preview') &&
|
||||
! is_null($user) &&
|
||||
! is_null($row['usrid'])) {
|
||||
|
||||
$this->result[$i]['nbprev'] += ( ! is_null($row['nb']) ? $row['nb'] : 0);
|
||||
$this->result[$i]['poidprev'] += ( ! is_null($row['poid']) ? $row['poid'] : 0);
|
||||
|
||||
$this->result[$i]['user'] = empty($row[$on]) ?
|
||||
"<i>" . $this->app->trans('report:: non-renseigne') . "</i>" : $row[$on];
|
||||
$total['nbprev'] += ( ! is_null($row['nb']) ? $row['nb'] : 0);
|
||||
$total['poidprev'] += ( ! is_null($row['poid']) ? $row['poid'] : 0);
|
||||
$this->result[$i]['usrid'] = $row['usrid'];
|
||||
}
|
||||
|
||||
@@ -601,12 +597,20 @@ class module_report_activity extends module_report
|
||||
if ($this->total > 0) {
|
||||
$this->result[$nb_row]['user'] = '<b>TOTAL</b>';
|
||||
$this->result[$nb_row]['nbdoc'] = '<b>' . $total['nbdoc'] . '</b>';
|
||||
$this->result[$nb_row]['poiddoc'] =
|
||||
'<b>' . p4string::format_octets($total['poiddoc']) . '</b>';
|
||||
$this->result[$nb_row]['nbprev'] = '<b>' . $total['nbprev'] . '</b>';
|
||||
$this->result[$nb_row]['poidprev'] =
|
||||
'<b>' . p4string::format_octets($total['poidprev']) . '</b>';
|
||||
}
|
||||
|
||||
foreach($this->result as $k=>$row) {
|
||||
$_row = array();
|
||||
foreach((array) $tab as $k2=>$f) {
|
||||
$_row[$k2] = array_key_exists($k2, $row) ? $row[$k2] : '';
|
||||
}
|
||||
$_row['usrid'] = array_key_exists('usrid', $row) ? $row['usrid'] : '';
|
||||
$this->result[$k] = $_row;
|
||||
}
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s) %s\n\n", __FILE__, __LINE__, var_export($this->result, true)), FILE_APPEND);
|
||||
|
||||
$this->total = sizeof($this->result);
|
||||
$this->calculatePages();
|
||||
$this->setDisplayNav();
|
||||
@@ -615,6 +619,7 @@ class module_report_activity extends module_report
|
||||
return $this->report;
|
||||
}
|
||||
|
||||
// ========================== ???????????????? ===========================
|
||||
public static function topTenUser(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox($sbas_id);
|
||||
@@ -627,12 +632,9 @@ class module_report_activity extends module_report
|
||||
|
||||
$params = [':site_id' => $app['conf']->get(['main', 'key'])];
|
||||
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax, 'log_docs.date');
|
||||
$params = array_merge($params, $datefilter['params']);
|
||||
|
||||
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
|
||||
$params = array_merge($params, $collfilter['params']);
|
||||
|
||||
/*
|
||||
$sql = "SELECT tt.usrid, tt.user, tt.final, tt.record_id, SUM(1) AS nb, SUM(size) AS poid
|
||||
FROM (
|
||||
SELECT DISTINCT(log.id), log.usrid, user, final, log_date.record_id
|
||||
@@ -642,12 +644,27 @@ class module_report_activity extends module_report
|
||||
WHERE log.site = :site_id
|
||||
AND log_date.action = 'download'
|
||||
AND (" . $datefilter['sql'] . ")" .
|
||||
(('' !== $collfilter['sql']) ? "AND (" . $collfilter['sql'] . ")" : '')
|
||||
. "
|
||||
(('' !== $collfilter['sql']) ? "AND (" . $collfilter['sql'] . ")" : '')
|
||||
. "
|
||||
) AS tt
|
||||
LEFT JOIN subdef AS s ON (s.record_id = tt.record_id)
|
||||
WHERE s.name = tt.final
|
||||
GROUP BY tt.user, tt.final";
|
||||
*/
|
||||
$sql = "SELECT tt.usrid, tt.user, tt.final, tt.record_id, SUM(1) AS nb, SUM(size) AS poid\n"
|
||||
. " FROM (\n"
|
||||
. " SELECT DISTINCT(log.id), log.usrid, user, final, log_docs.record_id\n"
|
||||
. " FROM (log_docs)\n"
|
||||
. " INNER JOIN log FORCE INDEX (date_site) ON (log.id = log_docs.log_id)\n"
|
||||
. " WHERE log.site = :site_id\n"
|
||||
. " AND log_docs.action = 'download'\n"
|
||||
. " AND (" . $datefilter['sql'] . ")\n"
|
||||
. ") AS tt\n"
|
||||
. "LEFT JOIN subdef AS s ON (s.record_id = tt.record_id)\n"
|
||||
. "WHERE s.name = tt.final\n"
|
||||
. "GROUP BY tt.user, tt.final";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
@@ -697,6 +714,7 @@ class module_report_activity extends module_report
|
||||
return $result;
|
||||
}
|
||||
|
||||
//============================= Dashboard =========================
|
||||
public static function activity(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox($sbas_id);
|
||||
@@ -704,12 +722,10 @@ class module_report_activity extends module_report
|
||||
$res = [];
|
||||
$datefilter =
|
||||
module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
$collfilter =
|
||||
module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
|
||||
|
||||
$params = [':site_id' => $app['conf']->get(['main', 'key'])];
|
||||
$params = array_merge($params, $datefilter['params'], $collfilter['params']);
|
||||
|
||||
$params = array_merge($params, $datefilter['params']);
|
||||
/*
|
||||
$sql = "
|
||||
SELECT tt.id, HOUR(tt.heures) AS heures
|
||||
FROM (
|
||||
@@ -717,9 +733,19 @@ class module_report_activity extends module_report
|
||||
FROM log AS log_date FORCE INDEX (date_site)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . "" .
|
||||
(('' !== $collfilter['sql']) ? "AND (" . $collfilter['sql'] . ")" : '')
|
||||
. " AND log_date.site = :site_id
|
||||
(('' !== $collfilter['sql']) ? "AND (" . $collfilter['sql'] . ")" : '')
|
||||
. " AND log_date.site = :site_id
|
||||
) AS tt";
|
||||
*/
|
||||
$sql = "SELECT tt.id, HOUR(tt.heures) AS heures\n"
|
||||
. " FROM (\n"
|
||||
. " SELECT DISTINCT(log_date.id), log_date.date AS heures\n"
|
||||
. " FROM log AS log_date FORCE INDEX (date_site)\n"
|
||||
. " WHERE " . $datefilter['sql'] . " AND !ISNULL(usrid)"
|
||||
. " AND log_date.site = :site_id\n"
|
||||
. " ) AS tt";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
@@ -744,6 +770,7 @@ class module_report_activity extends module_report
|
||||
return $res;
|
||||
}
|
||||
|
||||
//============================= Dashboard =========================
|
||||
public static function activityDay(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox($sbas_id);
|
||||
@@ -751,11 +778,10 @@ class module_report_activity extends module_report
|
||||
$result = array();
|
||||
$res = array();
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
|
||||
|
||||
$params = [':site_id' => $app['conf']->get(['main', 'key'])];
|
||||
$params = array_merge($params, $datefilter['params'], $collfilter['params']);
|
||||
|
||||
$params = array_merge($params, $datefilter['params']);
|
||||
/*
|
||||
$sql = "
|
||||
SELECT tt.ddate, COUNT( DATE_FORMAT( tt.ddate, '%d' ) ) AS activity
|
||||
FROM (
|
||||
@@ -763,10 +789,22 @@ class module_report_activity extends module_report
|
||||
FROM log AS log_date FORCE INDEX (date_site) INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . "
|
||||
AND log_date.site = :site_id" .
|
||||
(('' !== $collfilter['sql']) ? (" AND (" . $collfilter['sql'] . ")") : '')
|
||||
(('' !== $collfilter['sql']) ? (" AND (" . $collfilter['sql'] . ")") : '')
|
||||
. ") AS tt
|
||||
GROUP by tt.ddate
|
||||
ORDER BY tt.ddate ASC";
|
||||
*/
|
||||
$sql = "SELECT tt.ddate, COUNT( DATE_FORMAT( tt.ddate, '%d' ) ) AS activity\n"
|
||||
. " FROM (\n"
|
||||
. " SELECT DISTINCT(log_date.id), DATE_FORMAT( log_date.date, '%Y-%m-%d' ) AS ddate\n"
|
||||
. " FROM log AS log_date FORCE INDEX (date_site)\n"
|
||||
. " WHERE " . $datefilter['sql'] . "\n"
|
||||
. " AND log_date.site = :site_id AND !ISNULL(usrid)"
|
||||
. ") AS tt\n"
|
||||
. " GROUP by tt.ddate\n"
|
||||
. " ORDER BY tt.ddate ASC";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
@@ -785,19 +823,18 @@ class module_report_activity extends module_report
|
||||
return $res;
|
||||
}
|
||||
|
||||
//============================= Dashboard =========================
|
||||
public static function activityQuestion(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox($sbas_id);
|
||||
$conn = $databox->get_connection();
|
||||
$result = [];
|
||||
$datefilter =
|
||||
module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
$collfilter =
|
||||
module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
|
||||
$params = [':site_id' => $app['conf']->get(['main', 'key'])];
|
||||
$params = array_merge($params, $datefilter['params'], $collfilter['params']);
|
||||
$params = array_merge($params, $datefilter['params']);
|
||||
|
||||
/*
|
||||
$sql = "
|
||||
SELECT tt.usrid, tt.user, sum(1) AS nb
|
||||
FROM (
|
||||
@@ -807,10 +844,23 @@ class module_report_activity extends module_report
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . "
|
||||
AND log_date.site = :site_id" .
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
. ") AS tt
|
||||
GROUP BY tt.usrid
|
||||
ORDER BY nb DESC";
|
||||
*/
|
||||
$sql = "SELECT tt.usrid, tt.user, sum(1) AS nb\n"
|
||||
. " FROM (\n"
|
||||
. " SELECT DISTINCT(log_date.id), log_date.usrid, log_date.user\n"
|
||||
. " FROM (`log_search`)\n"
|
||||
. " INNER JOIN log AS log_date FORCE INDEX (date_site) ON (log_search.log_id = log_date.id)\n"
|
||||
. " WHERE " . $datefilter['sql'] . "\n"
|
||||
. " AND log_date.site = :site_id"
|
||||
. ") AS tt\n"
|
||||
. " GROUP BY tt.usrid\n"
|
||||
. " ORDER BY nb DESC";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
@@ -826,19 +876,18 @@ class module_report_activity extends module_report
|
||||
return $result;
|
||||
}
|
||||
|
||||
//============================= Dashboard =========================
|
||||
public static function activiteTopQuestion(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox($sbas_id);
|
||||
$conn = $databox->get_connection();
|
||||
$result = [];
|
||||
$datefilter =
|
||||
module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
$collfilter =
|
||||
module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
|
||||
$params = [':site_id' => $app['conf']->get(['main', 'key'])];
|
||||
$params = array_merge($params, $datefilter['params'], $collfilter['params']);
|
||||
$params = array_merge($params, $datefilter['params']);
|
||||
|
||||
/*
|
||||
$sql = "
|
||||
SELECT TRIM(tt.search) AS question, tt.usrid, tt.user, SUM(1) AS nb
|
||||
FROM (
|
||||
@@ -848,10 +897,23 @@ class module_report_activity extends module_report
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . "
|
||||
AND log_date.site = :site_id" .
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
. ") AS tt
|
||||
GROUP BY tt.search
|
||||
ORDER BY nb DESC";
|
||||
*/
|
||||
$sql = "SELECT TRIM(tt.search) AS question, tt.usrid, tt.user, SUM(1) AS nb\n"
|
||||
. " FROM (\n"
|
||||
. " SELECT DISTINCT(log_date.id), log_search.search, log_date.usrid, log_date.user\n"
|
||||
. " FROM (`log_search`)\n"
|
||||
. " INNER JOIN log AS log_date FORCE INDEX (date_site) ON (log_search.log_id = log_date.id)\n"
|
||||
. " WHERE " . $datefilter['sql'] . "\n"
|
||||
. " AND log_date.site = :site_id"
|
||||
. ") AS tt\n"
|
||||
. " GROUP BY tt.search\n"
|
||||
. " ORDER BY nb DESC";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
@@ -870,17 +932,19 @@ class module_report_activity extends module_report
|
||||
return $result;
|
||||
}
|
||||
|
||||
//============================= Dashboard =========================
|
||||
public static function activiteTopTenSiteView(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox($sbas_id);
|
||||
$conn = $databox->get_connection();
|
||||
$result = [];
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
|
||||
|
||||
$params = [];
|
||||
$params = array_merge($params, $datefilter['params'], $collfilter['params']);
|
||||
$params = array_merge($params, $datefilter['params']);
|
||||
|
||||
|
||||
/*
|
||||
$sql = "
|
||||
SELECT tt.referrer, SUM(1) AS nb_view
|
||||
FROM (
|
||||
@@ -889,10 +953,22 @@ class module_report_activity extends module_report
|
||||
INNER JOIN log AS log_date FORCE INDEX (date_site) ON (log_view.log_id = log_date.id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . "" .
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
. ") AS tt
|
||||
GROUP BY referrer
|
||||
ORDER BY nb_view DESC ";
|
||||
*/
|
||||
$sql = "SELECT tt.referrer, SUM(1) AS nb_view\n"
|
||||
. " FROM (\n"
|
||||
. " SELECT DISTINCT(log_date.id), referrer\n"
|
||||
. " FROM (log_view)\n"
|
||||
. " INNER JOIN log AS log_date FORCE INDEX (date_site) ON (log_view.log_id = log_date.id)\n"
|
||||
. " WHERE " . $datefilter['sql']
|
||||
. ") AS tt\n"
|
||||
. " GROUP BY referrer\n"
|
||||
. " ORDER BY nb_view DESC ";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
@@ -914,17 +990,17 @@ class module_report_activity extends module_report
|
||||
return $result;
|
||||
}
|
||||
|
||||
//============================= Dashboard =========================
|
||||
public static function activiteAddedDocument(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox($sbas_id);
|
||||
$conn = $databox->get_connection();
|
||||
$result = [];
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
|
||||
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax, 'log_docs.date');
|
||||
$params = [];
|
||||
$params = array_merge($params, $datefilter['params'], $collfilter['params']);
|
||||
$params = array_merge($params, $datefilter['params']);
|
||||
|
||||
/*
|
||||
$sql = "
|
||||
SELECT tt.ddate, COUNT( DATE_FORMAT( tt.ddate, '%d' ) ) AS activity
|
||||
FROM (
|
||||
@@ -934,10 +1010,22 @@ class module_report_activity extends module_report
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . " AND log_date.action = 'add' " .
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
. "
|
||||
. "
|
||||
) AS tt
|
||||
GROUP BY tt.ddate
|
||||
ORDER BY activity ASC ";
|
||||
*/
|
||||
$sql = "SELECT tt.ddate, COUNT( DATE_FORMAT( tt.ddate, '%d' ) ) AS activity\n"
|
||||
. " FROM (\n"
|
||||
. " SELECT DISTINCT(log.id), DATE_FORMAT(log_docs.date, '%Y-%m-%d') AS ddate\n"
|
||||
. " FROM (log_docs)\n"
|
||||
. " INNER JOIN log FORCE INDEX (date_site) ON (log_docs.log_id = log.id)\n"
|
||||
. " WHERE " . $datefilter['sql'] . " AND log_docs.action = 'add'"
|
||||
. " ) AS tt\n"
|
||||
. " GROUP BY tt.ddate\n"
|
||||
. " ORDER BY activity ASC ";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
@@ -951,17 +1039,17 @@ class module_report_activity extends module_report
|
||||
return $result;
|
||||
}
|
||||
|
||||
//============================= Dashboard =========================
|
||||
public static function activiteEditedDocument(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox($sbas_id);
|
||||
$conn = $databox->get_connection();
|
||||
$result = [];
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
|
||||
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax, 'log_docs.date');
|
||||
$params = [];
|
||||
$params = array_merge($params, $datefilter['params'], $collfilter['params']);
|
||||
$params = array_merge($params, $datefilter['params']);
|
||||
|
||||
/*
|
||||
$sql = "
|
||||
SELECT tt.ddate, COUNT( DATE_FORMAT( tt.ddate, '%d' ) ) AS activity
|
||||
FROM (
|
||||
@@ -970,10 +1058,22 @@ class module_report_activity extends module_report
|
||||
INNER JOIN log FORCE INDEX (date_site) ON (log_date.log_id = log.id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . " AND log_date.action = 'edit'" .
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
. ") AS tt
|
||||
GROUP BY tt.ddate
|
||||
ORDER BY activity ASC ";
|
||||
*/
|
||||
$sql = "SELECT tt.ddate, COUNT( DATE_FORMAT( tt.ddate, '%d' ) ) AS activity\n"
|
||||
. " FROM (\n"
|
||||
. " SELECT DISTINCT(log.id), DATE_FORMAT( log_docs.date, '%Y-%m-%d') AS ddate\n"
|
||||
. " FROM (log_docs)\n"
|
||||
. " INNER JOIN log FORCE INDEX (date_site) ON (log_docs.log_id = log.id)\n"
|
||||
. " WHERE " . $datefilter['sql'] . " AND log_docs.action = 'edit'"
|
||||
. ") AS tt\n"
|
||||
. " GROUP BY tt.ddate\n"
|
||||
. " ORDER BY activity ASC ";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
@@ -988,17 +1088,17 @@ class module_report_activity extends module_report
|
||||
return $result;
|
||||
}
|
||||
|
||||
//============================= Dashboard =========================
|
||||
public static function activiteAddedTopTenUser(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox($sbas_id);
|
||||
$conn = $databox->get_connection();
|
||||
$result = [];
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax, 'log_docs.date');
|
||||
|
||||
$params = [];
|
||||
$params = array_merge($params, $datefilter['params'], $collfilter['params']);
|
||||
|
||||
$params = array_merge($params, $datefilter['params']);
|
||||
/*
|
||||
$sql = "
|
||||
SELECT tt.usrid, tt.user, sum( 1 ) AS nb
|
||||
FROM (
|
||||
@@ -1007,10 +1107,23 @@ class module_report_activity extends module_report
|
||||
INNER JOIN log FORCE INDEX (date_site) ON (log_date.log_id = log.id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . " AND log_date.action = 'add'" .
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
. ") AS tt
|
||||
GROUP BY tt.usrid
|
||||
ORDER BY nb ASC ";
|
||||
*/
|
||||
$sql = ""
|
||||
. " SELECT tt.usrid, tt.user, sum( 1 ) AS nb\n"
|
||||
. " FROM (\n"
|
||||
. " SELECT DISTINCT(log.id), log.usrid, log.user\n"
|
||||
. " FROM (log_docs)\n"
|
||||
. " INNER JOIN log FORCE INDEX (date_site) ON (log_docs.log_id = log.id)\n"
|
||||
. " WHERE " . $datefilter['sql'] . " AND log_docs.action = 'add'"
|
||||
. ") AS tt\n"
|
||||
. " GROUP BY tt.usrid\n"
|
||||
. " ORDER BY nb ASC ";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -38,7 +38,7 @@ class module_report_connexion extends module_report
|
||||
*/
|
||||
public function __construct(Application $app, $arg1, $arg2, $sbas_id, $collist)
|
||||
{
|
||||
parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
|
||||
parent::__construct($app, $arg1, $arg2, $sbas_id, '');
|
||||
$this->title = $this->app->trans('report::Connexions');
|
||||
}
|
||||
|
||||
@@ -139,23 +139,26 @@ class module_report_connexion extends module_report
|
||||
$conn = $databox->get_connection();
|
||||
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
|
||||
|
||||
$params = array_merge([
|
||||
':site_id' => $app['conf']->get(['main', 'key'])
|
||||
],
|
||||
$datefilter['params'],
|
||||
$collfilter['params']
|
||||
$datefilter['params']
|
||||
);
|
||||
|
||||
$finalfilter = $datefilter['sql'] . ' AND ';
|
||||
$finalfilter .= $collfilter['sql'] . ' AND ';
|
||||
$finalfilter .= 'log_date.site = :site_id';
|
||||
|
||||
/*
|
||||
$sql = "SELECT COUNT(DISTINCT(log_date.id)) as nb
|
||||
FROM log as log_date FORCE INDEX (date_site)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
|
||||
WHERE " . $finalfilter;
|
||||
*/
|
||||
$sql = "SELECT COUNT(DISTINCT(log_date.id)) as nb\n"
|
||||
. " FROM log as log_date FORCE INDEX (date_site)\n"
|
||||
. " WHERE " . $finalfilter . "\n";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -80,7 +80,6 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
$tmp = new self($app, $sbasid, $sbas_coll, $dmin, $dmax);
|
||||
|
||||
$app['phraseanet.appbox']->set_data_to_cache($tmp, $cache_id);
|
||||
@@ -138,6 +137,7 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
|
||||
$this->report['nb_dl'] = module_report_download::getNbDl(
|
||||
$this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection
|
||||
);
|
||||
|
||||
//Get Number of connexions
|
||||
$this->report['nb_conn'] = module_report_connexion::getNbConn(
|
||||
$this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -21,16 +21,12 @@ class module_report_download extends module_report
|
||||
'activite' => 'log.activite',
|
||||
'fonction' => 'log.fonction',
|
||||
'usrid' => 'log.usrid',
|
||||
'coll_id' => 'log_colls.coll_id',
|
||||
'ddate' => "log_docs.date",
|
||||
'id' => 'log_docs.id',
|
||||
'log_id' => 'log_docs.log_id',
|
||||
'record_id' => 'log_docs.record_id',
|
||||
'final' => 'log_docs.final',
|
||||
'comment' => 'log_docs.comment',
|
||||
'size' => 'subdef.size',
|
||||
'mime' => 'subdef.mime',
|
||||
'file' => 'subdef.file'
|
||||
'comment' => 'log_docs.comment'
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -44,7 +40,7 @@ class module_report_download extends module_report
|
||||
*/
|
||||
public function __construct(Application $app, $arg1, $arg2, $sbas_id, $collist)
|
||||
{
|
||||
parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
|
||||
parent::__construct($app, $arg1, $arg2, $sbas_id, '');
|
||||
$this->title = $this->app->trans('report:: telechargements');
|
||||
}
|
||||
|
||||
@@ -55,9 +51,12 @@ class module_report_download extends module_report
|
||||
*/
|
||||
protected function buildReq($groupby = false, $on = false)
|
||||
{
|
||||
$this->setDateField('log_docs.date');
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
|
||||
$sql = $this->sqlBuilder('download')
|
||||
->setOn($on)->setGroupBy($groupby)->buildSql();
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
|
||||
$this->req = $sql->getSql();
|
||||
$this->params = $sql->getParams();
|
||||
$this->total = $sql->getTotalRows();
|
||||
@@ -102,6 +101,7 @@ class module_report_download extends module_report
|
||||
{
|
||||
$i = 0;
|
||||
$pref = parent::getPreff($app, $this->sbas_id);
|
||||
//// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s) %s\n\n", __FILE__, __LINE__, var_export($rs, true)), FILE_APPEND);
|
||||
|
||||
foreach ($rs as $row) {
|
||||
if ($this->enable_limit && ($i > $this->nb_record))
|
||||
@@ -112,23 +112,28 @@ class module_report_download extends module_report
|
||||
}
|
||||
|
||||
if (array_key_exists('record_id', $row)) {
|
||||
//// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s) %s\n\n", __FILE__, __LINE__, $row['record_id']), FILE_APPEND);
|
||||
try {
|
||||
$record = new \record_adapter($app, $this->sbas_id, $row['record_id']);
|
||||
$caption = $record->get_caption();
|
||||
foreach ($pref as $field) {
|
||||
//// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s) %s\n\n", __FILE__, __LINE__, $field), FILE_APPEND);
|
||||
try {
|
||||
$this->result[$i][$field] = $caption
|
||||
->get_field($field)
|
||||
->get_serialized_values();
|
||||
} catch (\Exception $e) {
|
||||
$this->result[$i][$field] = '';
|
||||
}
|
||||
}
|
||||
} catch (\Exception_Record_AdapterNotFound $e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($pref as $field) {
|
||||
try {
|
||||
$this->result[$i][$field] = $record->get_caption()
|
||||
->get_field($field)
|
||||
->get_serialized_values();
|
||||
} catch (\Exception $e) {
|
||||
foreach ($pref as $field) {
|
||||
$this->result[$i][$field] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
$i ++;
|
||||
//// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,13 +182,11 @@ class module_report_download extends module_report
|
||||
|
||||
$params = [':site_id' => $app['conf']->get(['main', 'key'])];
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
|
||||
$params = array_merge($params, $datefilter['params'], $collfilter['params']);
|
||||
$params = array_merge($params, $datefilter['params']);
|
||||
|
||||
$finalfilter = $datefilter['sql'] . ' AND ';
|
||||
$finalfilter .= $collfilter['sql'] . ' AND ';
|
||||
$finalfilter .= 'log.site = :site_id';
|
||||
|
||||
/*
|
||||
$sql = '
|
||||
SELECT SUM(1) AS nb
|
||||
FROM (
|
||||
@@ -198,6 +201,18 @@ class module_report_download extends module_report
|
||||
)
|
||||
) AS tt
|
||||
';
|
||||
*/
|
||||
$sql = "SELECT SUM(1) AS nb\n"
|
||||
. " FROM (\n"
|
||||
. " SELECT DISTINCT(log.id)\n"
|
||||
. " FROM log FORCE INDEX (date_site)"
|
||||
. " INNER JOIN log_docs"
|
||||
. " WHERE " . $finalfilter . "\n"
|
||||
. " AND ( log_docs.action = 'download' OR log_docs.action = 'mail' )\n"
|
||||
. " ) AS tt";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
@@ -213,8 +228,7 @@ class module_report_download extends module_report
|
||||
|
||||
$params = [':site_id' => $app['conf']->get(['main', 'key'])];
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
|
||||
$params = array_merge($params, $datefilter['params'], $collfilter['params']);
|
||||
$params = array_merge($params, $datefilter['params']);
|
||||
|
||||
$finalfilter = "";
|
||||
$array = [
|
||||
@@ -223,9 +237,8 @@ class module_report_download extends module_report
|
||||
];
|
||||
|
||||
$finalfilter .= $datefilter['sql'] . ' AND ';
|
||||
$finalfilter .= $collfilter['sql'] . ' AND ';
|
||||
$finalfilter .= 'log.site = :site_id';
|
||||
|
||||
/*
|
||||
$sql = '
|
||||
SELECT tt.id, tt.name, SUM(1) AS nb
|
||||
FROM (
|
||||
@@ -244,6 +257,20 @@ class module_report_download extends module_report
|
||||
) AS tt
|
||||
GROUP BY id, name
|
||||
';
|
||||
*/
|
||||
$sql = "SELECT tt.id, tt.name, SUM(1) AS nb\n"
|
||||
. " FROM (\n"
|
||||
. " SELECT DISTINCT(log.id) AS log_id, log_docs.record_id as id, subdef.name\n"
|
||||
. " FROM ( log )\n"
|
||||
. " INNER JOIN log_docs ON (log.id = log_docs.log_id)\n"
|
||||
. " INNER JOIN subdef ON (log_docs.record_id = subdef.record_id)\n"
|
||||
. " WHERE (" . $finalfilter . ")\n"
|
||||
. " AND ( log_docs.action = 'download' OR log_docs.action = 'mail' )\n"
|
||||
. " AND subdef.name = log_docs.final\n"
|
||||
. " ) AS tt\n"
|
||||
. " GROUP BY id, name\n";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -48,7 +48,8 @@ class module_report_nav extends module_report
|
||||
*/
|
||||
public function __construct(Application $app, $arg1, $arg2, $sbas_id, $collist)
|
||||
{
|
||||
parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
|
||||
// parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
|
||||
parent::__construct($app, $arg1, $arg2, $sbas_id, "");
|
||||
}
|
||||
|
||||
private function setTotalPourcent()
|
||||
@@ -60,12 +61,11 @@ class module_report_nav extends module_report
|
||||
$params = array_merge([], $report_filter['params']);
|
||||
|
||||
$sql = '
|
||||
SELECT SUM(1) AS total FROM (
|
||||
SELECT DISTINCT (log.id)
|
||||
SELECT COUNT(log.id) AS total
|
||||
FROM log FORCE INDEX (date_site)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE ' . $report_filter['sql'] . ' AND nav != ""
|
||||
) AS tt';
|
||||
WHERE ' . $report_filter['sql'] . ' AND nav != "" AND !ISNULL(usrid)';
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $sqlBuilder->getConnBas()->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
@@ -112,16 +112,14 @@ class module_report_nav extends module_report
|
||||
$params = array_merge([], $report_filter['params']);
|
||||
|
||||
$sql = '
|
||||
SELECT tt.nav, SUM(1) AS nb, ROUND((SUM(1) / ' . $this->total_pourcent . ' * 100), 1) AS pourcent
|
||||
FROM (
|
||||
SELECT DISTINCT(log.id), nav
|
||||
SELECT nav, SUM(1) AS nb, ROUND((SUM(1) / ' . $this->total_pourcent . ' * 100), 1) AS pourcent
|
||||
FROM log FORCE INDEX (date_site, nav)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE ' . $report_filter['sql'] . ' AND nav != ""
|
||||
) AS tt
|
||||
GROUP BY tt.nav
|
||||
WHERE ' . $report_filter['sql'] . ' AND nav != "" AND !ISNULL(usrid)
|
||||
GROUP BY nav
|
||||
ORDER BY nb DESC';
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$this->initialize();
|
||||
|
||||
$stmt = $sqlBuilder->getConnBas()->prepare($sql);
|
||||
@@ -171,16 +169,16 @@ class module_report_nav extends module_report
|
||||
$params = array_merge([], $report_filter['params']);
|
||||
|
||||
$sql = '
|
||||
SELECT tt.os, COUNT(os) AS nb, ROUND((COUNT(os)/' . $this->total_pourcent . '*100),1) AS pourcent
|
||||
FROM (
|
||||
SELECT DISTINCT(log.id), os
|
||||
SELECT os, COUNT(os) AS nb, ROUND((COUNT(os)/' . $this->total_pourcent . '*100),1) AS pourcent
|
||||
|
||||
FROM log FORCE INDEX (date_site, os)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE '. $report_filter['sql'] . ' AND os != ""
|
||||
) AS tt
|
||||
GROUP BY tt.os
|
||||
WHERE '. $report_filter['sql'] . ' AND os != "" AND !ISNULL(usrid)
|
||||
|
||||
GROUP BY os
|
||||
ORDER BY nb DESC';
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$this->initialize();
|
||||
|
||||
$stmt = $sqlBuilder->getConnBas()->prepare($sql);
|
||||
@@ -229,17 +227,17 @@ class module_report_nav extends module_report
|
||||
$params = array_merge([], $report_filter['params']);
|
||||
|
||||
$sql = '
|
||||
SELECT tt.res, COUNT(res) AS nb, ROUND((COUNT(res)/ ' . $this->total_pourcent . '*100),1) AS pourcent
|
||||
FROM (
|
||||
SELECT DISTINCT(log.id), res
|
||||
SELECT res, COUNT(res) AS nb, ROUND((COUNT(res)/ ' . $this->total_pourcent . '*100),1) AS pourcent
|
||||
|
||||
FROM log FORCE INDEX (date_site, res)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE '. $report_filter['sql'] . ' AND res != ""
|
||||
) AS tt
|
||||
GROUP BY tt.res
|
||||
WHERE '. $report_filter['sql'] . ' AND res != "" AND !ISNULL(usrid)
|
||||
|
||||
GROUP BY res
|
||||
ORDER BY nb DESC
|
||||
LIMIT 0, 10';
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$this->initialize();
|
||||
|
||||
$stmt = $sqlBuilder->getConnBas()->prepare($sql);
|
||||
@@ -291,15 +289,16 @@ class module_report_nav extends module_report
|
||||
$sql = "
|
||||
SELECT tt.combo, COUNT( tt.combo ) AS nb, ROUND((COUNT(tt.combo)/" . $this->total_pourcent . "*100), 1) AS pourcent
|
||||
FROM (
|
||||
SELECT DISTINCT(log.id), CONCAT( nav, '-', os ) AS combo
|
||||
SELECT CONCAT( nav, '-', os ) AS combo
|
||||
FROM log FORCE INDEX (date_site, os_nav)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE ". $report_filter['sql'] ." AND nav != '' AND os != ''
|
||||
WHERE ". $report_filter['sql'] ." AND nav != '' AND os != '' AND !ISNULL(usrid)
|
||||
) AS tt
|
||||
GROUP BY tt.combo
|
||||
ORDER BY nb DESC
|
||||
LIMIT 0 , 10";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$this->initialize();
|
||||
|
||||
$stmt = $sqlBuilder->getConnBas()->prepare($sql);
|
||||
@@ -351,14 +350,12 @@ class module_report_nav extends module_report
|
||||
$params = array_merge([], $report_filter['params']);
|
||||
|
||||
$sql = '
|
||||
SELECT tt.appli
|
||||
FROM (
|
||||
SELECT DISTINCT(log.id), appli
|
||||
SELECT appli
|
||||
FROM log FORCE INDEX (date_site, appli)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE ' . $report_filter['sql'] . ' AND appli != \'a:0:{}\'
|
||||
) AS tt
|
||||
GROUP BY tt.appli';
|
||||
WHERE ' . $report_filter['sql'] . ' AND appli != \'a:0:{}\' AND !ISNULL(usrid)
|
||||
GROUP BY appli';
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$this->initialize();
|
||||
|
||||
@@ -547,13 +544,14 @@ class module_report_nav extends module_report
|
||||
FROM (
|
||||
SELECT DISTINCT (log.id), version
|
||||
FROM log FORCE INDEX (date_site, nav, version)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE nav = :browser
|
||||
AND ". $report_filter['sql'] . "
|
||||
) AS tt
|
||||
GROUP BY version
|
||||
ORDER BY nb DESC";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -54,7 +54,7 @@ class module_report_push extends module_report
|
||||
protected function buildReq($groupby = false, $on = false)
|
||||
{
|
||||
$sqlBuilder = $this->sqlBuilder('action')->setGroupBy($groupby)->setOn($on)
|
||||
->setAction('push')->buildSql();
|
||||
->setAction('validate')->buildSql();
|
||||
$this->req = $sqlBuilder->getSql();
|
||||
$this->params = $sqlBuilder->getParams();
|
||||
$this->total = $sqlBuilder->getTotalRows();
|
||||
@@ -62,7 +62,7 @@ class module_report_push extends module_report
|
||||
|
||||
public function colFilter($field, $on = false)
|
||||
{
|
||||
$sqlBuilder = $this->sqlBuilder('action')->setAction('push');
|
||||
$sqlBuilder = $this->sqlBuilder('action')->setAction('validate');
|
||||
$var = $sqlBuilder->sqlDistinctValByField($field);
|
||||
$sql = $var['sql'];
|
||||
$params = $var['params'];
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -39,7 +39,7 @@ class module_report_question extends module_report
|
||||
*/
|
||||
public function __construct(Application $app, $arg1, $arg2, $sbas_id, $collist)
|
||||
{
|
||||
parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
|
||||
parent::__construct($app, $arg1, $arg2, $sbas_id, '');
|
||||
$this->title = $this->app->trans('report:: question');
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -27,7 +27,7 @@ class module_report_sqlconnexion extends module_report_sql implements module_rep
|
||||
if ($this->groupby == false) {
|
||||
$this->sql = "
|
||||
SELECT
|
||||
DISTINCT(log_colls.log_id),
|
||||
log.id,
|
||||
log.user,
|
||||
log.usrid,
|
||||
log.date as ddate,
|
||||
@@ -40,8 +40,9 @@ class module_report_sqlconnexion extends module_report_sql implements module_rep
|
||||
log.appli,
|
||||
log.ip
|
||||
FROM log FORCE INDEX (date_site)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE (" . $filter['sql'] .")";
|
||||
WHERE (" . $filter['sql'] .") AND !ISNULL(log.usrid)";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $this->sql), FILE_APPEND);
|
||||
|
||||
$stmt = $this->connbas->prepare($this->sql);
|
||||
$stmt->execute($this->params);
|
||||
@@ -59,12 +60,13 @@ class module_report_sqlconnexion extends module_report_sql implements module_rep
|
||||
FROM (
|
||||
SELECT DISTINCT(log.id), TRIM(" . $this->getTransQuery($this->groupby) . ") AS " . $this->groupby . "
|
||||
FROM log FORCE INDEX (date_site)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE (" . $filter['sql'] .")
|
||||
) AS tt
|
||||
GROUP BY " . $this->groupby. "
|
||||
ORDER BY nb DESC";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $this->sql), FILE_APPEND);
|
||||
|
||||
$stmt = $this->connbas->prepare($this->sql);
|
||||
$stmt->execute($this->params);
|
||||
$this->total_row = $stmt->rowCount();
|
||||
@@ -84,7 +86,6 @@ class module_report_sqlconnexion extends module_report_sql implements module_rep
|
||||
FROM (
|
||||
SELECT DISTINCT(log.id), ' . $this->getTransQuery($field) . ' AS val
|
||||
FROM log FORCE INDEX (date_site)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE (' . $filter['sql'] . ')
|
||||
) AS tt ORDER BY val ASC';
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -17,6 +17,7 @@ class module_report_sqldownload extends module_report_sql implements module_repo
|
||||
|
||||
public function __construct(Application $app, module_report $report)
|
||||
{
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
|
||||
parent::__construct($app, $report);
|
||||
if ($report->isInformative()) {
|
||||
$this->restrict = true;
|
||||
@@ -30,7 +31,9 @@ class module_report_sqldownload extends module_report_sql implements module_repo
|
||||
$filter = $this->filter->getReportFilter() ? : ['params' => [], 'sql' => false];
|
||||
$this->params = array_merge([], $filter['params']);
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
|
||||
if ($this->groupby == false) {
|
||||
/*
|
||||
$this->sql = "
|
||||
SELECT DISTINCT(log.id), log.user, log.societe, log.pays, log.activite, log_colls.coll_id,
|
||||
log.fonction, log.usrid, log_docs.date AS ddate, log_docs.record_id, log_docs.final, log_docs.comment
|
||||
@@ -38,31 +41,35 @@ class module_report_sqldownload extends module_report_sql implements module_repo
|
||||
INNER JOIN log FORCE INDEX (date_site) ON (log.id = log_docs.log_id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE (" .$filter['sql'] . ") AND (log_docs.action = 'download' OR log_docs.action = 'mail')";
|
||||
*/
|
||||
$this->sql = "
|
||||
SELECT log.id, log.user, log.societe, log.pays, log.activite, record.coll_id,
|
||||
log.fonction, log.usrid, log_docs.date AS ddate, log_docs.record_id, log_docs.final, log_docs.comment
|
||||
FROM log_docs
|
||||
INNER JOIN log FORCE INDEX (date_site) ON (log.id = log_docs.log_id)
|
||||
LEFT JOIN record ON (record.record_id=log_docs.record_id)
|
||||
WHERE (" .$filter['sql'] . ")
|
||||
AND !ISNULL(usrid)
|
||||
AND (log_docs.action = 'download' OR log_docs.action = 'mail')
|
||||
AND (log_docs.final = 'preview' OR log_docs.final = 'document')";
|
||||
|
||||
if ($this->restrict) {
|
||||
$this->sql .= ' AND (log_docs.final = "document" OR log_docs.final = "preview")';
|
||||
}
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $this->sql), FILE_APPEND);
|
||||
} else {
|
||||
$name = $this->groupby;
|
||||
$field = $this->getTransQuery($this->groupby);
|
||||
|
||||
if ($name == 'record_id' && $this->on == 'DOC') {
|
||||
$this->sql = '
|
||||
SELECT ' . $name . ', SUM(1) AS telechargement, tt.comment, tt.size, tt.file, tt.mime, tt.final
|
||||
SELECT ' . $name . ', SUM(1) AS telechargement, tt.comment, tt.final
|
||||
FROM (
|
||||
SELECT DISTINCT(log.id), TRIM( ' . $field . ' ) AS ' . $name . ', log_docs.comment, subdef.size, subdef.file, subdef.mime, log_docs.final
|
||||
SELECT log.id, TRIM( ' . $field . ' ) AS ' . $name . ', log_docs.comment, log_docs.final
|
||||
FROM log FORCE INDEX (date_site)
|
||||
INNER JOIN log_docs ON (log.id = log_docs.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 subdef ON (log_docs.record_id = subdef.record_id)';
|
||||
LEFT JOIN record ON (log_docs.record_id = record.record_id)';
|
||||
|
||||
$customFieldMap = [
|
||||
$field => $name,
|
||||
'log_docs.comment' => 'tt.comment',
|
||||
'subdef.size' => 'tt.size',
|
||||
'subdef.file' => 'tt.file',
|
||||
'subdef.mime' => 'tt.mime',
|
||||
'log_docs.final' => 'tt.final',
|
||||
];
|
||||
|
||||
@@ -73,9 +80,8 @@ class module_report_sqldownload extends module_report_sql implements module_repo
|
||||
SELECT DISTINCT(log.id), TRIM(' . $field . ') AS ' . $name . '
|
||||
FROM log FORCE INDEX (date_site)
|
||||
INNER JOIN log_docs ON (log.id = log_docs.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 subdef ON ( log_docs.record_id = subdef.record_id)';
|
||||
LEFT JOIN record ON (log_docs.record_id = record.record_id)';
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $this->sql), FILE_APPEND);
|
||||
} else {
|
||||
$this->sql = '
|
||||
SELECT ' . $name . ', SUM(1) AS nombre
|
||||
@@ -83,33 +89,37 @@ class module_report_sqldownload extends module_report_sql implements module_repo
|
||||
SELECT DISTINCT(log.id), TRIM( ' . $this->getTransQuery($this->groupby) . ') AS ' . $name . '
|
||||
FROM log FORCE INDEX (date_site)
|
||||
INNER JOIN log_docs ON (log.id = log_docs.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 subdef ON (record.record_id = subdef.record_id)';
|
||||
LEFT JOIN record ON (log_docs.record_id = record.record_id)';
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $this->sql), FILE_APPEND);
|
||||
}
|
||||
|
||||
$this->sql .= ' WHERE (subdef.name = log_docs.final) AND ' . $filter['sql'] . ' ';
|
||||
$this->sql .= 'AND ( log_docs.action = \'download\' OR log_docs.action = \'mail\') ';
|
||||
$this->sql .= $this->on == 'DOC' ? 'AND subdef.name = \'document\' ' : '';
|
||||
$this->sql .= ' WHERE ' . $filter['sql'] . ' ';
|
||||
$this->sql .= ' AND !ISNULL(usrid)';
|
||||
$this->sql .= ' AND (log_docs.action = \'download\' OR log_docs.action = \'mail\') ';
|
||||
$this->sql .= $this->on == 'DOC' ? ' AND (log_docs.final = "document") ' : ' AND (log_docs.final = "preview" OR log_docs.final = "document")';
|
||||
$this->sql .= ') as tt';
|
||||
$this->sql .= ' GROUP BY ' . $name . ' ' . ($name == 'record_id' && $this->on == 'DOC' ? ', final' : '');
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $this->sql), FILE_APPEND);
|
||||
}
|
||||
|
||||
$stmt = $this->connbas->prepare($this->sql);
|
||||
$stmt->execute($this->params);
|
||||
$this->total_row = $stmt->rowCount();
|
||||
$stmt->closeCursor();
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
|
||||
|
||||
if (count($customFieldMap) > 0) {
|
||||
$this->sql .= $this->filter->getOrderFilter($customFieldMap) ? : '';
|
||||
} else {
|
||||
$this->sql .= $this->filter->getOrderFilter() ? : '';
|
||||
$this->sql .= $this->filter->getOrderFilter() ? : '';
|
||||
}
|
||||
|
||||
if ($this->enable_limit) {
|
||||
$this->sql .= $this->filter->getLimitFilter() ? : '';
|
||||
}
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $this->sql), FILE_APPEND);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -124,12 +134,11 @@ class module_report_sqldownload extends module_report_sql implements module_repo
|
||||
SELECT DISTINCT(log.id), ' . $this->getTransQuery($field) . ' AS val
|
||||
FROM log FORCE INDEX (date_site)
|
||||
INNER JOIN log_docs ON (log.id = log_docs.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 subdef ON (log_docs.record_id = subdef.record_id)
|
||||
LEFT JOIN record ON (log_docs.record_id = record.record_id)
|
||||
WHERE (' . $filter['sql'] . ')
|
||||
AND !ISNULL(log.usrid)
|
||||
AND (log_docs.action = "download" OR log_docs.action = "mail")' .
|
||||
($this->on == 'DOC' ? ' AND subdef.name = "document"' : '') .
|
||||
($this->on == 'DOC' ? ' AND (log_docs.final = "document") ' : ' AND (log_docs.final = "preview" OR log_docs.final = "document")') .
|
||||
') AS tt';
|
||||
|
||||
$this->sql .= $this->filter->getOrderFilter() ? : '';
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -32,31 +32,12 @@ class module_report_sqlfilter
|
||||
$this->report = $report;
|
||||
}
|
||||
|
||||
public static function constructDateFilter($dmin, $dmax)
|
||||
public static function constructDateFilter($dmin, $dmax, $dateField = 'log_date.date')
|
||||
{
|
||||
return [
|
||||
'sql' => ($dmin && $dmax ? ' log_date.date > :date_min AND log_date.date < :date_max ' : false)
|
||||
, 'params' => ($dmin && $dmax ? [':date_min' => $dmin, ':date_max' => $dmax] : [])
|
||||
];
|
||||
}
|
||||
|
||||
public static function constructCollectionFilter(Application $app, $list_coll_id)
|
||||
{
|
||||
$ret = ['sql' => '', 'params' => []];
|
||||
$coll_filter = [];
|
||||
foreach (array_filter(explode(',', $list_coll_id)) as $val) {
|
||||
$val = \phrasea::collFromBas($app, $val);
|
||||
if ($val) {
|
||||
$coll_filter[] = 'log_colls.coll_id = ' . $val;
|
||||
}
|
||||
}
|
||||
$collections = array_unique($coll_filter);
|
||||
|
||||
if (count($collections) > 0) {
|
||||
$ret['sql'] = ' (' . implode(' OR ', $collections) . ') ';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
return array(
|
||||
'sql' => ($dmin && $dmax ? ' '.$dateField.' > :date_min AND '.$dateField.' < :date_max ' : false)
|
||||
, 'params' => ($dmin && $dmax ? array(':date_min' => $dmin, ':date_max' => $dmax) : array())
|
||||
);
|
||||
}
|
||||
|
||||
public function getCorFilter()
|
||||
@@ -66,25 +47,22 @@ class module_report_sqlfilter
|
||||
|
||||
public function getReportFilter()
|
||||
{
|
||||
$finalfilter = '';
|
||||
$sql = '';
|
||||
|
||||
$params = [':log_site' => $this->app['conf']->get(['main', 'key'])];
|
||||
|
||||
if ($this->filter['date'] && $this->filter['date']['sql'] !== '') {
|
||||
$finalfilter .= $this->filter['date']['sql'] . ' AND ';
|
||||
$sql .= $this->filter['date']['sql'] . ' AND ';
|
||||
$params = array_merge($params, $this->filter['date']['params']);
|
||||
}
|
||||
if ($this->filter['user'] && $this->filter['user']['sql'] !== '') {
|
||||
$finalfilter .= $this->filter['user']['sql'] . ' AND ';
|
||||
$sql .= $this->filter['user']['sql'] . ' AND ';
|
||||
$params = array_merge($params, $this->filter['user']['params']);
|
||||
}
|
||||
if ($this->filter['collection'] && $this->filter['collection']['sql'] !== '') {
|
||||
$finalfilter .= $this->filter['collection']['sql'] . ' AND ';
|
||||
$params = array_merge($params, $this->filter['collection']['params']);
|
||||
}
|
||||
$finalfilter .= ' log.site = :log_site';
|
||||
|
||||
return ['sql' => $finalfilter, 'params' => $params];
|
||||
$sql .= ' log.site = :log_site';
|
||||
|
||||
return array('sql' => $sql, 'params' => $params);
|
||||
}
|
||||
|
||||
public function getGvSitFilter()
|
||||
@@ -99,7 +77,7 @@ class module_report_sqlfilter
|
||||
|
||||
public function getUserIdFilter($id)
|
||||
{
|
||||
return ['sql' => "log.usrid = :usr_id_filter", 'params' => [':usr_id_filter' => $id]];
|
||||
return array('sql' => "log.usrid = :usr_id_filter", 'params' => array(':usr_id_filter' => $id));
|
||||
}
|
||||
|
||||
public function getDateFilter()
|
||||
@@ -112,11 +90,6 @@ class module_report_sqlfilter
|
||||
return $this->filter['user'];
|
||||
}
|
||||
|
||||
public function getCollectionFilter()
|
||||
{
|
||||
return $this->filter['collection'];
|
||||
}
|
||||
|
||||
public function getRecordFilter()
|
||||
{
|
||||
return $this->filter['record'];
|
||||
@@ -139,15 +112,19 @@ class module_report_sqlfilter
|
||||
private function dateFilter(module_report $report)
|
||||
{
|
||||
$this->filter['date'] = false;
|
||||
if ($report->getDmin() && $report->getDmax()) {
|
||||
$this->filter['date'] = [
|
||||
'sql' => ' (log.date > :date_min_f AND log.date < :date_max_f) '
|
||||
, 'params' => [
|
||||
':date_min_f' => $report->getDmin()
|
||||
, ':date_max_f' => $report->getDmax()
|
||||
]
|
||||
];
|
||||
$sql = "";
|
||||
if($report->getDmin()) {
|
||||
$sql = $report->getDateField().">=" . $this->conn->quote($report->getDmin());
|
||||
}
|
||||
if($report->getDmax()) {
|
||||
if($sql != "") {
|
||||
$sql .= " AND ";
|
||||
}
|
||||
$sql .= $report->getDateField()."<=" . $this->conn->quote($report->getDmax());
|
||||
}
|
||||
$this->filter['date'] = array(
|
||||
'sql' => $sql, 'params' => array()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -188,36 +165,6 @@ class module_report_sqlfilter
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private function collectionFilter(module_report $report)
|
||||
{
|
||||
$this->filter['collection'] = false;
|
||||
$coll_filter = [];
|
||||
|
||||
if ($report->getUserId() == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$tab = array_filter(explode(",", $report->getListCollId()));
|
||||
|
||||
if (count($tab) > 0) {
|
||||
foreach ($tab as $val) {
|
||||
$val = \phrasea::collFromBas($this->app, $val);
|
||||
if (!!$val) {
|
||||
$coll_filter[] = 'log_colls.coll_id = ' . $val;
|
||||
}
|
||||
}
|
||||
|
||||
$collections = array_unique($coll_filter);
|
||||
|
||||
if (count($collections) > 0) {
|
||||
$this->filter['collection'] = array('sql' => ' (' . implode(' OR ', array_unique($coll_filter)) . ') ', 'params' => array());
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private function recordFilter(module_report $report)
|
||||
{
|
||||
$this->filter['record'] = false;
|
||||
@@ -272,7 +219,6 @@ class module_report_sqlfilter
|
||||
$this->orderFilter($report);
|
||||
$this->recordFilter($report);
|
||||
$this->userFilter($report);
|
||||
$this->collectionFilter($report);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -25,11 +25,12 @@ class module_report_sqlquestion extends module_report_sql implements module_repo
|
||||
$this->params = array_merge([], $filter['params']);
|
||||
|
||||
if ($this->groupby == false) {
|
||||
$this->sql ="
|
||||
SELECT DISTINCT(log.id), log_search.date ddate, log_search.search, log.usrid, log.user, log.pays, log.societe, log.activite, log.fonction
|
||||
$this->sql =" SELECT log.id, log_search.date ddate, log_search.search, log.usrid, log.user, log.pays, log.societe, log.activite, log.fonction
|
||||
FROM log_search
|
||||
INNER JOIN log FORCE INDEX (date_site) ON (log.id = log_search.log_id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id) WHERE (" . $filter['sql'] .")";
|
||||
INNER JOIN log FORCE INDEX (date_site) ON (log.id = log_search.log_id) AND !ISNULL(usrid)
|
||||
WHERE (" . $filter['sql'] .")";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $this->sql), FILE_APPEND);
|
||||
|
||||
$stmt = $this->connbas->prepare($this->sql);
|
||||
$stmt->execute($this->params);
|
||||
@@ -48,12 +49,13 @@ class module_report_sqlquestion extends module_report_sql implements module_repo
|
||||
SELECT DISTINCT(log.id), TRIM(" . $this->getTransQuery($this->groupby) . ") AS " . $this->groupby . "
|
||||
FROM (`log_search`)
|
||||
INNER JOIN log FORCE INDEX (date_site) ON (log.id = log_search.log_id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE (" . $filter['sql'] .")
|
||||
) AS tt
|
||||
GROUP BY " . $this->groupby ."
|
||||
ORDER BY nb DESC";
|
||||
|
||||
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $this->sql), FILE_APPEND);
|
||||
|
||||
$stmt = $this->connbas->prepare($this->sql);
|
||||
$stmt->execute($this->params);
|
||||
$this->total_row = $stmt->rowCount();
|
||||
@@ -74,7 +76,6 @@ class module_report_sqlquestion extends module_report_sql implements module_repo
|
||||
SELECT DISTINCT(log.id), " . $this->getTransQuery($field) . " AS val
|
||||
FROM (`log_search`)
|
||||
INNER JOIN log FORCE INDEX (date_site) ON (log.id = log_search.log_id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE (" . $filter['sql'] . ")
|
||||
) as tt
|
||||
ORDER BY tt.val ASC";
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
* (c) 2005-2015 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -54,7 +54,7 @@ class module_report_validate extends module_report
|
||||
protected function buildReq($groupby = false, $on = false)
|
||||
{
|
||||
$sqlBuilder = $this->sqlBuilder('action')->setGroupBy($groupby)->setOn($on)
|
||||
->setAction('validate')->buildSql();
|
||||
->setAction('push')->buildSql();
|
||||
$this->req = $sqlBuilder->getSql();
|
||||
$this->params = $sqlBuilder->getParams();
|
||||
$this->total = $sqlBuilder->getTotalRows();
|
||||
@@ -62,7 +62,7 @@ class module_report_validate extends module_report
|
||||
|
||||
public function colFilter($field, $on = false)
|
||||
{
|
||||
$sqlBuilder = $this->sqlBuilder('action')->setAction('validate');
|
||||
$sqlBuilder = $this->sqlBuilder('action')->setAction('push');
|
||||
$var = $sqlBuilder->sqlDistinctValByField($field);
|
||||
$sql = $var['sql'];
|
||||
$params = $var['params'];
|
||||
|
Reference in New Issue
Block a user