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',
'coll_id' => 'record.coll_id',
'xml' => 'record.xml',
'ddate' => "log.date",
'ddate' => "log_docs.date",
'id' => 'log_docs.id',
'log_id' => 'log_docs.log_id',
'record_id' => 'log_docs.record_id',
@@ -39,6 +39,7 @@ class module_report_download extends module_report
'file' => 'subdef.file'
);
protected $isInformative;
/**
* constructor
*
@@ -277,5 +278,16 @@ class module_report_download extends module_report
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
{
protected $restrict = false;
public function __construct(module_report $report)
{
parent::__construct($report);
if($report->isInformative())
{
$this->restrict = true;
}
}
public function buildSql()
{
$registry = registry::get_instance();
$report_filters = $this->filter->getReportFilter();
$record_filters = $this->filter->getRecordFilter() ?: array('sql'=>'', 'params'=> array());
$this->params = array_merge($report_filters['params'], $record_filters['params']);
$record_filters = $this->filter->getRecordFilter() ? : array('sql' => '', 'params' => array());
$this->params = array_merge($report_filters['params'], $record_filters['params']);
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 .= ' 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 .= $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->execute($this->params);
$this->total_row = $stmt->rowCount();
$stmt->closeCursor();
$this->sql .= $this->filter->getLimitFilter() ?: '';
$this->sql .= $this->filter->getLimitFilter() ? : '';
}
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' : '';
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->execute($this->params);
$this->total = $stmt->rowCount();
$stmt->closeCursor();
$this->sql .= $this->filter->getLimitFilter() ?: '';
$this->sql .= $this->filter->getLimitFilter() ? : '';
}
return $this;