Esempio n. 1
0
 /**
  * @desc build the result from the specified sql
  * @param  array         $champ all the field from the request displayed in a array
  * @param  string        $sql   the request from buildreq
  * @return $this->result
  */
 protected function buildResult(Application $app, $rs)
 {
     $i = 0;
     $pref = parent::getPreff($app, $this->sbas_id);
     foreach ($rs as $row) {
         if ($this->enable_limit && $i > $this->nb_record) {
             break;
         }
         foreach ($this->champ as $column) {
             $this->formatResult($column, $row[$column], $i);
         }
         if (array_key_exists('record_id', $row)) {
             try {
                 $record = new \record_adapter($app, $this->sbas_id, $row['record_id']);
             } 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) {
                     $this->result[$i][$field] = '';
                 }
             }
         }
         $i++;
     }
 }
Esempio n. 2
0
 /**
  * @desc build the result from the specified sql
  * @param  array         $champ all the field from the request displayed in a array
  * @param  string        $sql   the request from buildreq
  * @return $this->result
  */
 protected function buildResult(Application $app, $rs)
 {
     $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) {
             break;
         }
         foreach ($this->champ as $column) {
             $this->formatResult($column, $row[$column], $i);
         }
         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) {
                 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);
     }
 }
Esempio n. 3
0
 /**
  * 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']]);
 }