public function descarga($clave)
 {
     $config = new ExporterConfig();
     $exporter = new Exporter($config);
     //indicador
     $indicador = Indicador::where('clave', '=', $clave)->first();
     $muestras = Muestra::where('id_indicador', '=', $indicador->id)->orderBy('anio', 'DESC')->orderBy('mes', 'ASC')->get();
     $salida = array();
     $salida[] = $this->encabezado_csv($indicador->frecuencia_muestreo);
     //recorrer las muestras
     foreach ($muestras as $muestra) {
         //decide que hacer
         switch ($indicador->frecuencia_muestreo) {
             case 0:
                 $salida[] = array($muestra->anio, $muestra->valor);
                 break;
             case 1:
                 $salida[] = array($muestra->anio, $muestra->mes, $muestra->valor);
                 break;
             case 2:
                 $val = $muestra->mes;
                 $val = $val - 300;
                 $salida[] = array($muestra->anio, $val, $muestra->valor);
                 break;
             case 3:
                 $salida[] = array($muestra->anio, $muestra->mes - 600, $muestra->valor);
                 break;
             case 4:
                 $salida[] = array($muestra->anio, $muestra->mes, $muestra->dia, $muestra->valor);
                 break;
         }
     }
     //el header
     header('Content-type: text/csv');
     header('Content-disposition: attachment;filename=' . $clave . '.csv');
     //exportar
     $exporter->export('php://output', $salida);
 }
예제 #2
0
 /**
  * @dataProvider provideNonBinaryMultibyteStrings
  */
 public function testNonBinaryStringExport($value, $expectedLength)
 {
     $this->assertRegExp("~'.{{$expectedLength}}'\$~s", $this->exporter->export($value));
 }
예제 #3
0
 function showExportRes()
 {
     /* update last page */
     $_SESSION['LASTPAGE'] = substr($_SESSION['LASTPAGE'], 0, strripos($_SESSION['LASTPAGE'], "res"));
     require_once "exporter.php";
     $exporter = new Exporter(loadvar(POST_PARAM_SUID));
     $exporter->export();
     $displaySysAdmin = new DisplaySysAdmin();
     return $displaySysAdmin->showExport();
 }