/**
  * Display information about a document
  *
  * @param  Request      $request
  * @return JsonResponse
  */
 public function doReportInformationDocument(Request $request)
 {
     $config = ['photo' => [$this->app->trans('report:: document'), 0, 0, 0, 0], 'record_id' => [$this->app->trans('report:: record id'), 0, 0, 0, 0], 'date' => [$this->app->trans('report:: date'), 0, 0, 0, 0], 'type' => [$this->app->trans('phrseanet:: sous definition'), 0, 0, 0, 0], 'titre' => [$this->app->trans('report:: titre'), 0, 0, 0, 0], 'taille' => [$this->app->trans('report:: poids'), 0, 0, 0, 0]];
     $config_dl = ['ddate' => [$this->app->trans('report:: date'), 0, 0, 0, 0], 'user' => [$this->app->trans('report:: utilisateurs'), 0, 0, 0, 0], 'final' => [$this->app->trans('phrseanet:: sous definition'), 0, 0, 0, 0], 'coll_id' => [$this->app->trans('report:: collections'), 0, 0, 0, 0], 'comment' => [$this->app->trans('report:: commentaire'), 0, 0, 0, 0], 'fonction' => [$this->app->trans('report:: fonction'), 0, 0, 0, 0], 'activite' => [$this->app->trans('report:: activite'), 0, 0, 0, 0], 'pays' => [$this->app->trans('report:: pays'), 0, 0, 0, 0], 'societe' => [$this->app->trans('report:: societe'), 0, 0, 0, 0]];
     //format conf according user preferences
     if ('' !== ($columnsList = $request->request->get('list_column', ''))) {
         $new_conf = $config_dl;
         $columns = explode(',', $columnsList);
         foreach (array_keys($config_dl) as $col) {
             if (!in_array($col, $columns)) {
                 unset($new_conf[$col]);
             }
         }
         $config_dl = $new_conf;
     }
     try {
         $record = new \record_adapter($this->app, $request->request->get('sbasid'), $request->request->get('rid'));
     } catch (\Exception $e) {
         $this->app->abort(404);
     }
     $what = new \module_report_nav($this->app, $request->request->get('dmin'), $request->request->get('dmax'), $request->request->get('sbasid'), $request->request->get('collection'));
     $what->setPeriode('');
     $what->setCsv(false);
     $what->setPrint(false);
     /** @var \record_adapter $record */
     $reportArray = $what->buildTabUserWhat($record->get_base_id(), $record->get_record_id(), $config);
     $title = $what->getTitle();
     $html = $this->render('report/ajax_data_content.html.twig', ['result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false]);
     $from = $request->request->get('from', '');
     if ('TOOL' === $from) {
         $what->setTitle('');
         return $this->app->json(['rs' => $html, 'display_nav' => false, 'title' => $title]);
     }
     if ('DASH' !== $from && 'PUSHDOC' !== $from) {
         $download = new \module_report_download($this->app, $request->request->get('dmin'), $request->request->get('dmax'), $request->request->get('sbasid'), $request->request->get('collection'));
         $mapColumnTitleToSqlField = $download->getTransQueryString();
         $currentfilter = [];
         if ('' !== ($serializedFilter = $request->request->get('liste_filter', ''))) {
             $currentfilter = @unserialize(urldecode($serializedFilter));
         }
         $filter = new \module_report_filter($this->app, $currentfilter, $mapColumnTitleToSqlField);
         if ('' !== ($filterColumn = $request->request->get('filter_column', ''))) {
             $field = current(explode(' ', $filterColumn));
             $value = $request->request->get('filter_value', '');
             if ($request->request->get('liste') == 'on') {
                 return $this->app->json(['diag' => $this->render('report/colFilter.html.twig', ['result' => $download->colFilter($field), 'field' => $field]), 'title' => $this->app->trans('filtrer les resultats sur la colonne %colonne%', ['%colonne%' => $field])]);
             }
             if ($field === $value) {
                 $filter->removeFilter($field);
             } else {
                 $filter->addFilter($field, '=', $value);
             }
         }
         $filter->addfilter('record_id', '=', $record->get_record_id());
         $download->setFilter($filter->getTabFilter());
         $download->setOrder('ddate', 'DESC');
         $download->setTitle($this->app->trans('report:: historique des telechargements'));
         $download->setConfig(false);
         $reportArray = $download->buildReport($config_dl);
         if ($request->request->get('printcsv') == 'on') {
             $download->setPrettyString(false);
             return $this->getCSVResponse($download, 'info_document');
         }
         $html .= $this->render('report/ajax_data_content.html.twig', ['result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false]);
         return $this->app->json(['rs' => $html, 'display_nav' => false, 'title' => $title]);
     }
     if ($this->getConf()->get(['registry', 'modules', 'anonymous-report']) == false && $from !== 'DOC' && $from !== 'DASH' && $from !== 'GEN' && $from !== 'PUSHDOC') {
         $conf = ['identifiant' => [$this->app->trans('report:: identifiant'), 0, 0, 0, 0], 'nom' => [$this->app->trans('report:: nom'), 0, 0, 0, 0], 'mail' => [$this->app->trans('report:: email'), 0, 0, 0, 0], 'adresse' => [$this->app->trans('report:: adresse'), 0, 0, 0, 0], 'tel' => [$this->app->trans('report:: telephone'), 0, 0, 0, 0]];
         $info = new \module_report_nav($this->app, $request->request->get('dmin'), $request->request->get('dmax'), $request->request->get('sbasid'), $request->request->get('collection'));
         $info->setPeriode('');
         $info->setConfig(false);
         $info->setTitle($this->app->trans('report:: utilisateur'));
         $reportArray = $info->buildTabGrpInfo(false, [], $request->request->get('user'), $conf, false);
         if ($request->request->get('printcsv') == 'on' && isset($download)) {
             return $this->getCSVResponse($this->app, $info, 'info_user');
         }
         $html .= $this->render('report/ajax_data_content.html.twig', ['result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false]);
         return $this->app->json(['rs' => $html, 'display_nav' => false, 'title' => $title]);
     }
     return $this->app->json(['rs' => $html, 'display_nav' => false, 'title' => $title]);
 }
예제 #2
0
파일: Root.php 프로젝트: nlegoff/Phraseanet
 /**
  * Display instance document report
  *
  * @param  Application  $app
  * @param  Request      $request
  * @return JsonResponse
  */
 public function doReportDocuments(Application $app, Request $request)
 {
     $document = new \module_report_download($app, $request->request->get('dmin'), $request->request->get('dmax'), $request->request->get('sbasid'), $request->request->get('collection'));
     $conf_pref = [];
     foreach (\module_report::getPreff($app, $request->request->get('sbasid')) as $field) {
         $conf_pref[strtolower($field)] = [$field, 0, 0, 0, 0];
     }
     $conf = array_merge(['telechargement' => [$app->trans('report:: telechargements'), 1, 0, 0, 0], 'record_id' => [$app->trans('report:: record id'), 1, 1, 1, 0], 'final' => [$app->trans('phraseanet:: sous definition'), 1, 0, 1, 1], 'file' => [$app->trans('report:: fichier'), 1, 0, 0, 1], 'mime' => [$app->trans('report:: type'), 1, 0, 1, 1], 'size' => [$app->trans('report:: taille'), 1, 0, 1, 1]], $conf_pref);
     if ($request->request->get('printcsv') == 'on') {
         $document->setHasLimit(false);
         $document->setPrettyString(false);
         $this->doReport($app, $request, $document, $conf, 'record_id');
         return $this->getCSVResponse($app, $document, 'documents');
     }
     $report = $this->doReport($app, $request, $document, $conf, 'record_id');
     if ($report instanceof Response) {
         return $report;
     }
     return $app->json(['rs' => $app['twig']->render('report/ajax_data_content.html.twig', ['result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => true]), 'display_nav' => $report['display_nav'], 'next' => $report['next_page'], 'prev' => $report['previous_page'], 'page' => $report['page'], 'filter' => sizeof($report['filter']) > 0 ? serialize($report['filter']) : '', 'col' => $report['active_column'], 'limit' => $report['nb_record']]);
 }
예제 #3
0
 /**
  * @desc fill the dash results for the current sbas
  * @return <void>
  */
 public function process()
 {
     try {
         //Get number of DLs
         $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);
         if ($this->app['conf']->get(['registry', 'modules', 'anonymous-report']) == false) {
             /**
              * get Top ten user of
              * number of dl doc, prev
              * number of weight dl by doc, prev
              */
             $top = module_report_activity::topTenUser($this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection);
             $this->report['top_ten_user_doc'] = $top['top_ten_doc'];
             $this->report['top_ten_user_prev'] = $top['top_ten_prev'];
             $this->report['top_ten_user_poiddoc'] = $top['top_ten_poiddoc'];
             $this->report['top_ten_user_poidprev'] = $top['top_ten_poidprev'];
         }
         /**
          *  get avtivity by hour
          */
         $this->report['activity'] = module_report_activity::activity($this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection);
         // get activty by day
         $this->report['activity_day'] = module_report_activity::activityDay($this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection);
         // get Most document and preview DL
         $topdl = module_report_download::getTopDl($this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection);
         $this->report['top_dl_preview'] = $topdl['preview'];
         $this->report['top_dl_document'] = $topdl['document'];
         if ($this->app['conf']->get(['registry', 'modules', 'anonymous-report']) == false) {
             // get users that ask the most questions
             $this->report['ask'] = module_report_activity::activityQuestion($this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection);
         }
         //get the refferer
         $this->report['top_ten_site'] = module_report_activity::activiteTopTenSiteView($this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection);
         //Get the most asked questions
         $this->report['top_ten_question'] = module_report_activity::activiteTopQuestion($this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection);
         //get the  number of added docuùments
         $this->report['activity_added'] = module_report_activity::activiteAddedDocument($this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection);
         //get number of edited document
         $this->report['activity_edited'] = module_report_activity::activiteEditedDocument($this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection);
         if ($this->app['conf']->get(['registry', 'modules', 'anonymous-report']) == false) {
             //get users that add the most documents
             $this->report['top_ten_added'] = module_report_activity::activiteAddedTopTenUser($this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection);
         }
     } catch (DBALException $e) {
     }
     return;
 }