Example #1
0
 /**
  * Export the data in the model into a particular format. Formats depend on
  * the formats available in the reports api.
  * @param $params
  * @return unknown_type
  * @see Report
  */
 public function export($params)
 {
     switch ($params[0]) {
         case "pdf":
             $report = new PDFReport();
             break;
         case "html":
             $report = new HTMLReport();
             $report->htmlHeaders = true;
             break;
         case "csv":
             if ($params[1] == "") {
                 $report = new CSVReport();
                 $this->model->datastore->dateFormat = 2;
             } else {
                 if ($params[1] == "template") {
                     $report = new CSVReport();
                     $table = new TableContent($this->model->getLabels(), array());
                     $report->add($table);
                     $report->output();
                 }
             }
             break;
         case "xls":
             $report = new XLSReport();
             break;
     }
     $title = new TextContent($this->label);
     $title->style["size"] = 12;
     $title->style["bold"] = true;
     $headers = $this->model->getLabels();
     $fieldNames = $this->model->getFieldNames();
     array_shift($fieldNames);
     $data = $this->model->get(array("fields" => $fieldNames));
     //$data = $this->model->formatData();
     $table = new TableContent($headers, $data);
     $table->style["decoration"] = true;
     $report->add($title, $table);
     $report->output();
 }