Esempio n. 1
0
 public function __construct(Application $app, module_report $report)
 {
     parent::__construct($app, $report);
     if ($report->isInformative()) {
         $this->restrict = true;
     }
 }
Esempio n. 2
0
 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;
     }
 }
Esempio n. 3
0
 public function __construct(Application $app, module_report $report)
 {
     parent::__construct($app, $report);
 }
Esempio n. 4
0
 public function buildTabInfoNav($tab = false, $navigator)
 {
     $databox = $this->app['phraseanet.appbox']->get_databox($this->sbas_id);
     $conn = $databox->get_connection();
     $this->title = $this->app->trans('report:: Information sur le navigateur %name%', ['%name%' => $navigator]);
     $sqlBuilder = new module_report_sql($this->app, $this);
     $filter = $sqlBuilder->getFilters();
     $report_filter = $filter->getReportFilter();
     $params = array_merge($report_filter['params'], [':browser' => $navigator]);
     $sql = "\n            SELECT DISTINCT(tt.version), COUNT(tt.version) as nb\n            FROM (\n                SELECT DISTINCT (log.id), version\n                FROM log FORCE INDEX (date_site, nav, version)\n                INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)\n                WHERE nav = :browser\n                AND " . $report_filter['sql'] . "\n            ) AS tt\n            GROUP BY version\n            ORDER BY nb DESC";
     $stmt = $conn->prepare($sql);
     $stmt->execute($params);
     $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $this->setChamp($rs);
     $this->setDisplay($tab);
     $this->result = $rs;
     $this->total = sizeof($this->result);
     $this->calculatePages();
     $this->setDisplayNav();
     $this->setReport();
     return $this->report;
 }
Esempio n. 5
0
 public function buildTabInfoNav($tab = false, $navigator)
 {
     $databox = $this->app->findDataboxById($this->sbas_id);
     $conn = $databox->get_connection();
     $this->title = $this->app->trans('report:: Information sur le navigateur %name%', ['%name%' => $navigator]);
     $sqlBuilder = new module_report_sql($this->app, $this);
     $filter = $sqlBuilder->getFilters();
     $report_filter = $filter->getReportFilter();
     $params = array_merge($report_filter['params'], [':browser' => $navigator]);
     $sql = "\n            SELECT DISTINCT(tt.version), COUNT(tt.version) as nb\n            FROM (\n                SELECT DISTINCT (log.id), version\n                FROM log FORCE INDEX (date_site, nav, version)\n                WHERE nav = :browser\n                AND " . $report_filter['sql'] . "\n            ) AS tt\n            GROUP BY version\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);
     $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $this->setChamp($rs);
     $this->setDisplay($tab);
     $this->result = $rs;
     $this->total = sizeof($this->result);
     $this->calculatePages();
     $this->setDisplayNav();
     $this->setReport();
     return $this->report;
 }
Esempio n. 6
0
 /**
  * Get the detail of download by users
  *
  * @param array  $tab config for the html table
  * @param String $on
  *
  * @return array
  */
 public function getDetailDownload($tab = false, $on = "")
 {
     empty($on) ? $on = "user" : "";
     //by default always report on user
     //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 = "\n                SELECT TRIM(" . $on . ") AS " . $on . ", SUM(1) AS nb, log_docs.final, log.usrid\n                FROM log_docs\n                    INNER JOIN log FORCE INDEX (date_site) ON (log.id = log_docs.log_id)\n                    LEFT JOIN record ON (record.record_id = log_docs.record_id)\n                WHERE (" . $filter['sql'] . ") AND !ISNULL(usrid)\n                AND (log_docs.action = 'download' OR log_docs.action = 'mail')\n                AND (log_docs.final = 'preview' OR log_docs.final = 'document')\n                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);
     $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $save_user = "";
     $i = -1;
     $total = ['nbdoc' => 0, 'nbprev' => 0];
     $this->setChamp($rs);
     $this->setDisplay($tab);
     foreach ($rs as $row) {
         $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) {
                     unset($this->result[$i]);
                 }
             }
             $i++;
             $this->result[$i]['nbprev'] = 0;
             $this->result[$i]['nbdoc'] = 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]['user'] = empty($row[$on]) ? "<i>" . $this->app->trans('report:: non-renseigne') . "</i>" : $row[$on];
             $total['nbdoc'] += $this->result[$i]['nbdoc'];
             $this->result[$i]['usrid'] = $row['usrid'];
         }
         //preview info
         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]['user'] = empty($row[$on]) ? "<i>" . $this->app->trans('report:: non-renseigne') . "</i>" : $row[$on];
             $total['nbprev'] += !is_null($row['nb']) ? $row['nb'] : 0;
             $this->result[$i]['usrid'] = $row['usrid'];
         }
         $save_user = $user;
     }
     unset($this->result[$i]);
     $nb_row = $i + 1;
     $this->total = $nb_row;
     if ($this->total > 0) {
         $this->result[$nb_row]['user'] = '******';
         $this->result[$nb_row]['nbdoc'] = '<b>' . $total['nbdoc'] . '</b>';
         $this->result[$nb_row]['nbprev'] = '<b>' . $total['nbprev'] . '</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();
     $this->setReport();
     return $this->report;
 }
Esempio n. 7
0
 /**
  * Get the deail of download by users
  *
  * @param array  $tab config for the html table
  * @param String $on
  *
  * @return array
  */
 public function getDetailDownload($tab = false, $on = "")
 {
     empty($on) ? $on = "user" : "";
     //by default always report on user
     //set title
     $this->title = $this->app->trans('report:: Detail des telechargements');
     $sqlBuilder = new module_report_sql($this->app, $this);
     $filter = $sqlBuilder->getFilters()->getReportFilter();
     $params = array_merge([], $filter['params']);
     $sql = "\n            SELECT tt.usrid, TRIM(" . $on . ") AS " . $on . ", tt.final, sum(1) AS nb, sum(size) AS poid\n            FROM (\n                SELECT DISTINCT(log.id), TRIM(" . $on . ") AS " . $on . ", log_docs.record_id, log_docs.final, log.usrid\n                FROM log_docs\n                    INNER JOIN log FORCE INDEX (date_site) ON (log.id = log_docs.log_id)\n                    INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)\n                    INNER JOIN record ON (record.record_id = log_docs.record_id)\n                WHERE (" . $filter['sql'] . ")\n                AND (log_docs.action = 'download' OR log_docs.action = 'mail')\n            ) AS tt\n            LEFT JOIN subdef FORCE INDEX (unicite) ON (tt.record_id = subdef.record_id)\n            WHERE subdef.name = tt.final\n            GROUP BY " . $on . ", usrid\n            ORDER BY nb DESC;";
     $stmt = $sqlBuilder->getConnBas()->prepare($sql);
     $stmt->execute($params);
     $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $save_user = "";
     $i = -1;
     $total = ['nbdoc' => 0, 'poiddoc' => 0, 'nbprev' => 0, 'poidprev' => 0];
     $this->setChamp($rs);
     $this->setDisplay($tab);
     foreach ($rs as $row) {
         $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) {
                     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') && !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'];
         }
         $save_user = $user;
     }
     unset($this->result[$i]);
     $nb_row = $i + 1;
     $this->total = $nb_row;
     if ($this->total > 0) {
         $this->result[$nb_row]['user'] = '******';
         $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>';
     }
     $this->total = sizeof($this->result);
     $this->calculatePages();
     $this->setDisplayNav();
     $this->setReport();
     return $this->report;
 }