fix #138 report / user downloads

This commit is contained in:
Nicolas Le Goff
2012-01-03 16:12:41 +01:00
parent c70755e9ec
commit 6872ceb3db
4 changed files with 34 additions and 15 deletions

View File

@@ -28,7 +28,7 @@ class module_report_download extends module_report
'usrid' => 'log.usrid', 'usrid' => 'log.usrid',
'coll_id' => 'record.coll_id', 'coll_id' => 'record.coll_id',
'xml' => 'record.xml', 'xml' => 'record.xml',
'ddate' => "log.date", 'ddate' => "log_docs.date",
'id' => 'log_docs.id', 'id' => 'log_docs.id',
'log_id' => 'log_docs.log_id', 'log_id' => 'log_docs.log_id',
'record_id' => 'log_docs.record_id', 'record_id' => 'log_docs.record_id',
@@ -39,6 +39,7 @@ class module_report_download extends module_report
'file' => 'subdef.file' 'file' => 'subdef.file'
); );
protected $isInformative;
/** /**
* constructor * constructor
* *
@@ -277,5 +278,16 @@ class module_report_download extends module_report
return $array; return $array;
} }
public function IsInformative()
{
return $this->isInformative;
}
public function setIsInformative($isInformative)
{
$this->isInformative = $isInformative;
}
} }

View File

@@ -18,17 +18,23 @@
class module_report_sqldownload extends module_report_sql implements module_report_sqlReportInterface class module_report_sqldownload extends module_report_sql implements module_report_sqlReportInterface
{ {
protected $restrict = false;
public function __construct(module_report $report) public function __construct(module_report $report)
{ {
parent::__construct($report); parent::__construct($report);
if($report->isInformative())
{
$this->restrict = true;
}
} }
public function buildSql() public function buildSql()
{ {
$registry = registry::get_instance(); $registry = registry::get_instance();
$report_filters = $this->filter->getReportFilter(); $report_filters = $this->filter->getReportFilter();
$record_filters = $this->filter->getRecordFilter() ?: array('sql'=>'', 'params'=> array()); $record_filters = $this->filter->getRecordFilter() ? : array('sql' => '', 'params' => array());
$this->params = array_merge($report_filters['params'], $record_filters['params']); $this->params = array_merge($report_filters['params'], $record_filters['params']);
if ($this->groupby == false) if ($this->groupby == false)
{ {
@@ -58,17 +64,19 @@ class module_report_sqldownload extends module_report_sql implements module_repo
$this->sql .= $report_filters['sql'] ? : ''; $this->sql .= $report_filters['sql'] ? : '';
$this->sql .= ' AND ( log_docs.action = \'download\' OR log_docs.action = \'mail\')'; $this->sql .= ' AND ( log_docs.action = \'download\' OR log_docs.action = \'mail\')';
if($this->restrict)
$this->sql .= ' AND ( log_docs.final = "document" OR log_docs.final = "preview")';
$this->sql .= empty($record_filters['sql']) ? '' : ' AND ( ' . $record_filters['sql'] . ' )'; $this->sql .= empty($record_filters['sql']) ? '' : ' AND ( ' . $record_filters['sql'] . ' )';
$this->sql .= $this->filter->getOrderFilter() ?: ''; $this->sql .= $this->filter->getOrderFilter() ? : '';
// var_dump(str_replace(array_keys($this->params), array_values($this->params), $this->sql), $this->sql, $this->params);
$stmt = $this->connbas->prepare($this->sql); $stmt = $this->connbas->prepare($this->sql);
$stmt->execute($this->params); $stmt->execute($this->params);
$this->total_row = $stmt->rowCount(); $this->total_row = $stmt->rowCount();
$stmt->closeCursor(); $stmt->closeCursor();
$this->sql .= $this->filter->getLimitFilter() ?: ''; $this->sql .= $this->filter->getLimitFilter() ? : '';
} }
else else
{ {
@@ -141,14 +149,15 @@ class module_report_sqldownload extends module_report_sql implements module_repo
$this->sql .= ( $name == 'record_id' && $this->on == 'DOC') ? ' , final' : ''; $this->sql .= ( $name == 'record_id' && $this->on == 'DOC') ? ' , final' : '';
if ($this->filter->getOrderFilter()) $this->sql .= $this->filter->getOrderFilter(); if ($this->filter->getOrderFilter())
$this->sql .= $this->filter->getOrderFilter();
$stmt = $this->connbas->prepare($this->sql); $stmt = $this->connbas->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->getLimitFilter() ?: ''; $this->sql .= $this->filter->getLimitFilter() ? : '';
} }
return $this; return $this;

View File

@@ -396,8 +396,9 @@ function getHistory($obj, $param, $twig, $conf, $dl = false, $title)
elseif (!empty($param['on']) && !empty($param['user'])) elseif (!empty($param['on']) && !empty($param['user']))
$filter->addfilter($param['on'], '=', $param['user']); $filter->addfilter($param['on'], '=', $param['user']);
if ($dl) if ($dl)
$filter->addfilter("(log_docs.final = 'document'", "OR", "log_docs.final = 'preview')"); {
$obj->setIsInformative(true);
}
$tab_filter = $filter->getTabFilter(); $tab_filter = $filter->getTabFilter();
$obj->setFilter($tab_filter); $obj->setFilter($tab_filter);

View File

@@ -129,6 +129,7 @@ iframe{
padding: 0 auto; padding: 0 auto;
clear:both; clear:both;
margin-bottom:10px; margin-bottom:10px;
overflow:auto;
} }
.report-table table { .report-table table {
@@ -417,15 +418,11 @@ table.tablesorter tr th.SortDown {
} }
.onload{ .onload{
background-image:url(ajax-loader.gif);
background-position:center center;
background-repeat:no-repeat;
}
.onloadd{
background-image:url(ajax-loader2.gif); background-image:url(ajax-loader2.gif);
background-position:center center; background-position:center center;
background-repeat:no-repeat; background-repeat:no-repeat;
} }
.ui-tabs, .ui-tabs .ui-tabs-panel{ .ui-tabs, .ui-tabs .ui-tabs-panel{
padding:0; padding:0;
} }