Inheritance: extends Pimcore\Model\AbstractModel
Esempio n. 1
0
 /**
  * @return array
  */
 public function load()
 {
     $properties = array();
     $propertiesData = $this->db->fetchAll($this->model->getFilter(), $this->model->getOrder());
     foreach ($propertiesData as $propertyData) {
         $properties[] = Config::getByName($propertyData["id"]);
     }
     $this->model->setReports($properties);
     return $properties;
 }
Esempio n. 2
0
 /**
  * @return Listing
  */
 protected function getListing()
 {
     $config = \Pimcore\Model\Tool\CustomReport\Config::getByName($this->reportId);
     $configuration = $config->getDataSourceConfig();
     $adapter = \Pimcore\Model\Tool\CustomReport\Config::getAdapter($configuration, $config);
     $result = $adapter->getData(null, $this->emailFieldName, 'ASC', null, null);
     $this->list = $result['data'];
     $this->elementsTotal = intval($result["total"]);
     $this->emailAddresses = [];
     foreach ($this->list as $row) {
         if (isset($row[$this->emailFieldName])) {
             $this->emailAddresses[] = $row[$this->emailFieldName];
         }
     }
     return $this->list;
 }
Esempio n. 3
0
 public function downloadCsvAction()
 {
     set_time_limit(300);
     $sort = $this->getParam("sort");
     $dir = $this->getParam("dir");
     $filters = $this->getParam("filter") ? json_decode($this->getParam("filter"), true) : null;
     $drillDownFilters = $this->getParam("drillDownFilters", null);
     $includeHeaders = $this->getParam('headers', false);
     $config = CustomReport\Config::getByName($this->getParam("name"));
     $columns = $config->getColumnConfiguration();
     $fields = [];
     foreach ($columns as $column) {
         if ($column['export']) {
             $fields[] = $column['name'];
         }
     }
     $configuration = $config->getDataSourceConfig();
     //if many rows returned as an array than use the first row. Fixes: #782
     $configuration = is_array($configuration) ? $configuration[0] : $configuration;
     $adapter = CustomReport\Config::getAdapter($configuration, $config);
     $result = $adapter->getData($filters, $sort, $dir, null, null, $fields, $drillDownFilters);
     $exportFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/report-export-" . uniqid() . ".csv";
     @unlink($exportFile);
     $fp = fopen($exportFile, 'w');
     if ($includeHeaders) {
         fputcsv($fp, $fields);
     }
     foreach ($result['data'] as $row) {
         fputcsv($fp, array_values($row));
     }
     fclose($fp);
     header('Content-type: text/csv; charset=UTF-8');
     header("Content-Length: " . filesize($exportFile));
     header("Content-Disposition: attachment; filename=\"export.csv\"");
     while (@ob_end_flush()) {
     }
     flush();
     readfile($exportFile);
     exit;
 }
Esempio n. 4
0
 /**
  * @return array
  */
 public static function getReportsList()
 {
     $dir = Model\Tool\CustomReport\Config::getWorkingDir();
     $reports = array();
     $files = scandir($dir);
     foreach ($files as $file) {
         if (strpos($file, ".xml")) {
             $name = str_replace(".xml", "", $file);
             $reports[] = array("id" => $name, "text" => $name);
         }
     }
     return $reports;
 }
Esempio n. 5
0
 public function getAvailableReportsAction()
 {
     $task = $this->getParam("task");
     if ($task === 'list') {
         $reportList = \Pimcore\Model\Tool\CustomReport\Config::getReportsList();
         $availableReports = [];
         foreach ($reportList as $report) {
             $availableReports[] = ['id' => $report['id'], 'text' => $report['text']];
         }
         $this->_helper->json(['data' => $availableReports]);
     } elseif ($task === 'fieldNames') {
         $reportId = $this->getParam("reportId");
         $report = \Pimcore\Model\Tool\CustomReport\Config::getByName($reportId);
         $columnConfiguration = $report->getColumnConfiguration();
         $availableColumns = [];
         foreach ($columnConfiguration as $column) {
             if ($column['display']) {
                 $availableColumns[] = ['name' => $column['name']];
             }
         }
         $this->_helper->json(['data' => $availableColumns]);
     }
 }
            $name = str_replace(".xml", "", $file);
            $thumbnail = \Pimcore\Model\Tool\Qrcode\Config::getByName($name);
            $thumbnail = object2array($thumbnail);
            $thumbnail["id"] = $thumbnail["name"];
            unset($thumbnail["name"]);
            $json->insertOrUpdate($thumbnail, $thumbnail["id"]);
        }
    }
    // move data
    rename($dir, $legacyFolder . "/qrcodes");
}
// SQL REPORTS
$dir = PIMCORE_CONFIGURATION_DIRECTORY . "/sqlreport";
if (is_dir($dir)) {
    $file = Pimcore\Config::locateConfigFile("custom-reports.json");
    $json = \Pimcore\Db\JsonFileTable::get($file);
    $json->truncate();
    $files = scandir($dir);
    foreach ($files as $file) {
        if (strpos($file, ".xml")) {
            $name = str_replace(".xml", "", $file);
            $thumbnail = \Pimcore\Model\Tool\CustomReport\Config::getByName($name);
            $thumbnail = object2array($thumbnail);
            $thumbnail["id"] = $thumbnail["name"];
            unset($thumbnail["name"]);
            $json->insertOrUpdate($thumbnail, $thumbnail["id"]);
        }
    }
    // move data
    rename($dir, $legacyFolder . "/sqlreport");
}