3 Комити f0f445c9c9 ... 5b9d05190f

Аутор SHA1 Порука Датум
  Hugo 5b9d05190f Vista de matriz en reporte пре 4 година
  Hugo 656ceccdd9 Vistas пре 4 година
  Hugo 7ce08952d5 Comandos пре 4 година

+ 126 - 6
commands/CopyController.php

@@ -530,13 +530,14 @@ class CopyController extends Controller {
       "TV_JUA_5_1",
     ],
     "rt-MOm8-" => [
-      "2107_3_MEX",
+      "107_3_MEX",
       "MEX_CDMX_94_5",
       "MEX_CDMX_100_9",
       "105_3_MEX",
       "MEX_CDMX_90_5",
       "MEX_CDMX_96_1",
       "MEX_CDMX_104_1",
+      "MEX_CDMX_98_5",
     ],
     "S1eMpr3" => [
       "CEN88_5",
@@ -757,6 +758,83 @@ class CopyController extends Controller {
     "8Duwg4qe" => [
       "106_1_MTY",
       "106_9_MTY",
+    ],
+    "mZOHHxIN" => [
+      "AM_AGU_AGU_1130",
+      "AM_DUR_DUR_1370",
+      "AM_TAM_MAT_1420",
+      "AM_NL_MON_770",
+      "AM_NL_MON_1090",
+      "AM_NL_MON_1190",
+      "AM_NL_MON_630",
+      "AM_NL_MON_660",
+      "AM_NL_MON_540",
+      "AM_HID_PAC_1240",
+      "AM_TAM_REY_1170",
+      "AM_NL_NGG_600",
+      "AM_NL_NGG_690",
+      "AM_NL_NGG_1480",
+      "AM_PUE_SPCH_1170",
+      "AM_PUE_SPCH_1120",
+      "AM_PUE_SPCH_1210",
+      "AM_PUE_SPCH_920",
+      "AM_PUE_SPCH_1250",
+      "AM_TLA_TLA_1430"
+    ],
+    "T9ng0M4J" => [
+      "AM_CDMX_1470",
+      "AM_CDMX_1410",
+      "AM_CDMX_1380",
+      "AM_CDMX_660",
+      "AM_CDMX_1000",
+      "AM_CDMX_940",
+      "AM_CDMX_970",
+      "AM_CDMX_1530",
+      "AM_CDMX_900",
+      "AM_CDMX_730",
+      "AM_CDMX_1180",
+      "AM_CDMX_710",
+      "AM_CDMX_620",
+      "AM_CDMX_590",
+      "AM_CDMX_1350",
+      "AM_CDMX_540",
+      "AM_CDMX_560",
+      "AM_CDMX_860",
+      "AM_CDMX_1150"
+    ],
+    "lWMy70IH" => [
+      "AM_CDMX_1220",
+      "AM_CDMX_1260",
+      "AM_CDMX_1590",
+      "AM_CDMX_1650",
+      "AM_CDMX_830",
+      "AM_CDMX_690",
+      "AM_CDMX_760",
+      "AM_CDMX_1030",
+      "AM_CDMX_1440",
+      "AM_JAL_GUA_1150",
+      "AM_JAL_GUA_820",
+      "AM_JAL_GUA_1280",
+      "AM_JAL_GUA_1250",
+      "AM_JAL_GUA_700",
+      "AM_JAL_GUA_790",
+      "AM_JAL_GUA_1190",
+      "AM_OAX_OAX_990",
+      "AM_OAX_OAX_570",
+      "AM_MEX_TOL_1040",
+      "AM_MEX_TOL_1600",
+    ],
+    "5m24geWA" => [
+      "AM_SIN_CUL_750",
+      "AM_SIN_CUL_1150",
+      "AM_CHI_JUA_1490",
+      "AM_CHI_JUA_1000",
+      "AM_CHI_JUA_640",
+      "AM_CHI_JUA_1300",
+      "AM_CHI_JUA_800",
+      "AM_CHI_JUA_1240",
+      "AM_CHI_JUA_860",
+      "AM_BCS_PAZ_1180",
     ]
   ];
 
@@ -775,13 +853,13 @@ class CopyController extends Controller {
   }
 
   public function actionIndex() {
-    $dbr = \Yii::$app->dbr;
+    $db = \Yii::$app->dbw;
     while(true) {
 
       $archivos = (new Query())
         ->from("file")
         ->innerJoin("box", "box.id = file.box")
-        ->andWhere([">=", "[[timestamp]] at time zone box.timezone", new Expression("now() - interval '2 days'")])
+        ->andWhere(["between", "[[timestamp]] at time zone box.timezone", '2021-12-25 08:40:00', '2021-12-26 00:00:00']) // new Expression("now() - interval '2 days'")])
         ->orderBy(["timestamp" => SORT_ASC]);
 
       $condicion = ["OR"];
@@ -792,7 +870,7 @@ class CopyController extends Controller {
 
       // $this->stdout($archivos->createCommand()->getRawSql() . "\n");
 
-      foreach($archivos->each(100, $dbr) as $archivo) {
+      foreach($archivos->each(100, $db) as $archivo) {
         try {
           \Yii::$app->getDb()->createCommand()
             ->insert("file", [
@@ -803,9 +881,9 @@ class CopyController extends Controller {
               "timestamp" => $archivo["timestamp"]
             ])
             ->execute();
-          $this->stdout("{$archivo["hash"]} {$archivo["box"]} {$archivo["station"]} {$archivo["timestamp"]}\n");
+          $this->stdout("{$archivo["hash"]} {$archivo["timestamp"]} {$archivo["station"]}\n");
         } catch(\Exception $e) {
-          $this->stdout("{$archivo["hash"]} {$archivo["box"]} {$archivo["station"]} {$archivo["timestamp"]} ya existe\n");
+          $this->stdout("{$archivo["hash"]} {$archivo["timestamp"]} {$archivo["station"]} ya existe\n");
         }
       }
 
@@ -864,4 +942,46 @@ class CopyController extends Controller {
     $this->stdout("Proceso terminado en: {$tiempo}\n");
   }
 
+  public function actionPorFecha() {
+    $db = \Yii::$app->dbw;
+    $inicio = time();
+    $archivos = (new Query())
+      ->from("file")
+      ->innerJoin("box", "box.id = file.box")
+      ->andWhere([">=", "[[timestamp]] at time zone box.timezone", "{$this->fi} 00:00:00"])
+      ->andWhere(["<", "[[timestamp]] at time zone box.timezone", "{$this->ff} 00:00:00"])
+      ->orderBy(["timestamp" => SORT_ASC]);
+
+    // $total = (clone $archivos)->count();
+    // $this->stdout("Total: {$total}\n");
+
+    // $this->stdout($archivos->createCommand()->getRawSql() . "\n");
+    // return;
+    $cont = 0;
+    foreach($archivos->each(100, $db) as $archivo) {
+      $estacion = str_pad($archivo["station"], 20, " ", STR_PAD_RIGHT);
+      $ciudad = str_pad($archivo["box"], 12, " ", STR_PAD_RIGHT);
+      try {
+        \Yii::$app->getDb()->createCommand()
+          ->insert("file", [
+            "hash" => $archivo["hash"],
+            "box" => $archivo["box"],
+            "station" => $archivo["station"],
+            "filename" => $archivo["filename"],
+            "timestamp" => $archivo["timestamp"]
+          ])
+          ->execute();
+
+        $this->stdout("{$archivo["hash"]} {$archivo["timestamp"]} {$ciudad} {$estacion} \n");
+      } catch(\Exception $e) {
+        $this->stdout("{$archivo["hash"]} {$archivo["timestamp"]} {$ciudad} {$estacion} Error\n");
+      }
+      $cont++;
+    }
+
+    $tiempo = time() - $inicio;
+
+    $this->stdout("Proceso terminado en: {$tiempo}\n");
+  }
+
 }

+ 160 - 3
commands/SyncCompleteController.php

@@ -11,6 +11,20 @@ use yii\helpers\ArrayHelper;
 
 class SyncCompleteController extends Controller {
 
+  public $ciudad = null;
+  public $estacion = null;
+  public $fi = null;
+  public $ff = null;
+
+  public function options($actionId) {
+    return [
+      'ciudad',
+      'estacion',
+      'fi',
+      'ff'
+    ];
+  }
+
   public function actionIndex() {
     $estados = [
       'AGUASCALIENTES' => 'AGU',
@@ -78,7 +92,8 @@ class SyncCompleteController extends Controller {
         ->select("hash, box, station, filename, [[timestamp]] at time zone box.timezone as timestamp")
         ->from("file")
         ->innerJoin("box", "box.id = file.box")
-        ->andWhere([">=", "[[timestamp]] at time zone box.timezone", new Expression("now() - interval '2 day'")])
+        ->andWhere([">=", "[[timestamp]] at time zone box.timezone", '2021-12-24 00:00:00'])
+        // ->andWhere([">=", "[[timestamp]] at time zone box.timezone", new Expression("now() - interval '6 day'")])
         // ->andWhere(["<=", "[[timestamp]] at time zone box.timezone", '2021-10-01 00:00:00'])
         ->orderBy(["timestamp" => $order]);
 
@@ -137,15 +152,157 @@ class SyncCompleteController extends Controller {
             $errores = json_encode($modelo->getFirstErrors());
             $this->stdout("Error al guardar {$modelo->hash} {$errores}\n");
           }
+          $this->stdout("{$modelo->hash} {$modelo->archivo}\n");
         } catch(\Exception $e) {
-          $this->stdout("Error al guardar {$modelo->hash} {$modelo->archivo}\n");
+          $this->stdout("{$modelo->hash} {$modelo->archivo} ya existe\n");
         }
         $count++;
       }
-      $vuelta = $inicio - time();
+      $vuelta = time() - $inicio;
       $this->stdout("Vuelta: {$vuelta}\n");
     }
     return ExitCode::OK;
   }
 
+  public function actionPorFecha() {
+    if(!$this->fi || !$this->ff) {
+      $this->stdout("Fecha inicial y final requeridas\n");
+      return ExitCode::OK;
+    }
+    $estados = [
+      'AGUASCALIENTES' => 'AGU',
+      'BAJA CALIFORNIA' => 'BCN',
+      'BAJA CALIFORNIA SUR' => 'BCS',
+      'CAMPECHE' => 'CAM',
+      'CHIAPAS' => 'CHP',
+      'CHIHUAHUA' => 'CHH',
+      'CIUDAD DE MÉXICO' => 'CMX',
+      'COAHUILA' => 'COA',
+      'COLIMA' => 'COL',
+      'DURANGO' => 'DUR',
+      'GUANAJUATO' => 'GUA',
+      'GUERRERO' => 'GRO',
+      'HIDALGO' => 'HID',
+      'JALISCO' => 'JAL',
+      'MEXICO' => 'MEX',
+      'MICHOACAN' => 'MIC',
+      'MORELOS' => 'MOR',
+      'NAYARIT' => 'NAY',
+      'NUEVO LEON' => 'NLE',
+      'OAXACA' => 'OAX',
+      'PUEBLA' => 'PUE',
+      'QUERETARO' => 'QUE',
+      'QUINTANA ROO' => 'ROO',
+      'SAN LUIS POTOSI' => 'SLP',
+      'SINALOA' => 'SIN',
+      'SONORA' => 'SON',
+      'TABASCO' => 'TAB',
+      'TAMAULIPAS' => 'TAM',
+      'TLAXCALA' => 'TLA',
+      'VERACRUZ' => 'VER',
+      'YUCATAN' => 'YUC',
+      'ZACATECAS' => 'ZAC'
+    ];
+    $order = SORT_ASC;
+
+    $ciudadEstacion = (new Query())
+      ->select(["idCiudad", "idEstacion"])
+      ->from("box")
+      ->innerJoin("CiudadEstacion", "box.id = {{CiudadEstacion}}.[[idCiudad]]")
+      ->andWhere([
+        "box.activo" => true
+      ])
+      ->andWhere("[[idGrupo]] is not null")
+      ->all();
+    $idCiudades = ArrayHelper::getColumn($ciudadEstacion, "idCiudad");
+    $ciudades = (new Query())
+      ->select(["id", "nombre", "idEstado", "timezone", "tipo"])
+      ->from("box")
+      ->where(["id" => $idCiudades])
+      ->indexBy("id")
+      ->all();
+    $idEstaciones = ArrayHelper::getColumn($ciudadEstacion, "idEstacion");
+    $estaciones = (new Query())
+      ->select(["id", "clave", "siglas", "frecuencia", "descripcion"])
+      ->from("Estacion")
+      ->andWhere(["id" => $idEstaciones])
+      ->indexBy("clave")
+      ->all();
+
+    $inicio = time();
+    $archivos = (new Query())
+      ->select("hash, box, station, filename, [[timestamp]] at time zone box.timezone as timestamp")
+      ->from("file")
+      ->innerJoin("box", "box.id = file.box")
+      ->andWhere([">=", "[[timestamp]] at time zone box.timezone", "{$this->fi} 00:00:00"])
+      // ->andWhere([">=", "[[timestamp]] at time zone box.timezone", new Expression("now() - interval '6 day'")])
+      ->andWhere(["<=", "[[timestamp]] at time zone box.timezone", "{$this->ff} 00:00:00"])
+      ->orderBy(["timestamp" => $order]);
+
+    // $this->stdout("{$archivos->createCommand()->getRawSql()}\n");
+
+    $count = 0;
+    foreach($archivos->each() as $archivo) {
+      if(!isset($ciudades[$archivo["box"]]) || !isset($estaciones[$archivo["station"]])) {
+        continue;
+      }
+      $modelo = new Descarga();
+      $modelo->hash = $archivo["hash"];
+      $modelo->estacion = $archivo["station"];
+      $modelo->archivo = $archivo["filename"];
+      $modelo->ciudad = $archivo["box"];
+      $modelo->pc = null;
+      $modelo->fecha = $archivo["timestamp"];
+      $modelo->descargado = false;
+      $modelo->nombre = basename($archivo["filename"]);
+      $ciudad = $ciudades[$archivo["box"]];
+      $estacion = $estaciones[$archivo["station"]];
+      $fecha = \DateTime::createFromFormat("Y-m-d H:i:s", $archivo["timestamp"]);
+      $siglas = explode("-", $estacion["siglas"]);
+      $tipo = "";
+      $senal = $siglas[0];
+      if(isset($siglas[1])) {
+        $tipo = $siglas[1];
+      }
+      if($tipo === "") {
+        if($ciudad["tipo"] === "tv") {
+          $tipo = "TDT";
+        } elseif ($ciudad["tipo"] === "radio") {
+          $tipo = "FM";
+        } else {
+          $tipo = "AM";
+        }
+      }
+      $nombreCiudad = $ciudad["idEstado"];
+      if($tipo === "AM") {
+        $desc = explode(",", $estacion["descripcion"]);
+        $nombreCiudad = $estacion["descripcion"];
+        if(isset($desc[1])) {
+          $nombreCiudad = $desc[1];
+        }
+      }
+      if(isset($estados[$nombreCiudad])) {
+        $nombreCiudad = $estados[$nombreCiudad];
+      }
+      $nombreCiudad = str_replace(" ", "_", trim($nombreCiudad));
+      $y = $fecha->format("Y");
+      $m = $fecha->format("m");
+      $d = $fecha->format("d");
+      $modelo->ruta = "{$y}/{$tipo}/{$nombreCiudad}/{$senal}/{$m}/{$d}";
+      try {
+        if(!$modelo->save()) {
+          $errores = json_encode($modelo->getFirstErrors());
+          $this->stdout("Error al guardar {$modelo->hash} {$errores}\n");
+        }
+        $this->stdout("{$modelo->hash} {$modelo->archivo}\n");
+      } catch(\Exception $e) {
+        $this->stdout("{$modelo->hash} {$modelo->archivo} ya existe\n");
+      }
+      $count++;
+    }
+    $vuelta = time() - $inicio;
+    $this->stdout("Vuelta: {$vuelta}\n");
+    return ExitCode::OK;
+  }
+
 }

+ 6 - 1
commands/SyncController.php

@@ -16,6 +16,7 @@ class SyncController extends Controller {
   public $estacion = null;
   public $fi = null;
   public $ff = null;
+  public $pc = null;
 
   public function options($actionID) {
     return [
@@ -24,7 +25,8 @@ class SyncController extends Controller {
       'ciudad',
       'estacion',
       'fi',
-      'ff'
+      'ff',
+      'pc'
     ];
   }
 
@@ -304,6 +306,9 @@ class SyncController extends Controller {
       $modelo->archivo = $archivo["filename"];
       $modelo->ciudad = $archivo["box"];
       $modelo->pc = null;
+      if($this->pc !== null) {
+        $modelo->pc = $this->pc;
+      }
       $modelo->fecha = $archivo["timestamp"];
       $modelo->descargado = false;
       $modelo->nombre = basename($archivo["filename"]);

+ 133 - 0
controllers/ReporteController.php

@@ -0,0 +1,133 @@
+<?php
+
+namespace app\controllers;
+
+use yii\db\Query;
+use yii\web\Controller;
+
+class ReporteController extends Controller {
+
+  public function actionDescarga() {
+    $req = \Yii::$app->getRequest();
+    $pc = trim($req->get("pc", ""));
+    $st = trim($req->get("st", ""));
+    $fi = trim($req->get("fi", "2021-12-01"));
+    $ff = trim($req->get("ff", ""));
+    $sql = intval($req->get("sql", "")) === 1;
+    $json = intval($req->get("json", "")) === 1;
+
+    $query = (new Query())
+      ->select([
+        "{{Estacion}}.id",
+        "{{Estacion}}.clave",
+        "{{Estacion}}.siglas",
+        "{{Estacion}}.frecuencia",
+        "ciudad",
+        "pc",
+        "to_char(fecha, 'YYYY-MM-DD') as fecha",
+        "extract(epoch from to_char(fecha, 'YYYY-MM-DD')::DATE) as epoch",
+        "count(estacion) filter (where descargado = true) as descargados",
+        "count(estacion) filter (where descargado = false) as pendientes",
+        "count(estacion) as total"
+      ])
+      ->from("Descarga")
+      ->innerJoin("Estacion", "{{Estacion}}.clave = {{Descarga}}.estacion")
+      ->andWhere(['not', ['pc' => null]])
+      ->groupBy(["{{Estacion}}.id", "to_char(fecha, 'YYYY-MM-DD')", "ciudad", "pc"])
+      ->orderBy([
+        "pc" => SORT_ASC,
+        "clave" => SORT_ASC,
+        "fecha" => SORT_ASC,
+      ]);
+    
+    if($fi !== "") {
+      $query->andWhere([">=", "fecha", "{$fi} 00:00:00"]);
+    }
+  
+    if($ff !== "") {
+      $query->andWhere(["<=", "fecha", "{$ff} 23:59:59"]);
+    }
+
+    if($pc !== "") {
+      $aux = explode(",", $pc);
+      $pcs = [];
+      foreach($aux as $p) {
+        $v = trim($p);
+        if(!empty($v)) {
+          $pcs[] = $v;
+        }
+      }
+      $query->andWhere(["pc" => $pcs]);
+    }
+
+    if($st !== "") {
+      $aux = explode(",", $st);
+      $sts = [];
+      foreach($aux as $p) {
+        $v = trim($p);
+        if(!empty($v)) {
+          $sts[] = $v;
+        }
+      }
+      $query->andWhere(["estacion" => $sts]);
+    }
+
+    if($sql) {
+      \Yii::$app->getResponse()->format = \yii\web\Response::FORMAT_RAW;
+      return $query->createCommand()->getRawSql();
+    }
+
+    $aux = $query->all();
+    $primer = null;
+    $ultimo = null;
+    if(!empty($aux)) {
+      $tz = new \DateTimeZone("America/Mexico_City");
+      $primer = \DateTime::createFromFormat("Y-m-d", $aux[0]['fecha'], $tz);
+      $ultimo = \DateTime::createFromFormat("Y-m-d", $aux[count($aux) - 1]['fecha'], $tz);
+      $primer->setTime(0, 0, 0);
+      $ultimo->setTime(0, 0, 0);
+    }
+    $descargas = [];
+    $estaciones = [];
+    foreach($aux as $d) {
+      if(!isset($estaciones[$d['pc']]) || (isset($estaciones[$d['pc']]) && !isset($estaciones[$d['pc']][$d['clave']]))) {
+        $estaciones[$d['pc']][$d['clave']] = [
+          "clave" => $d['clave'],
+          "siglas" => $d['siglas'],
+          "ciudad" => $d['ciudad'],
+          "frecuencia" => $d['frecuencia']
+        ];
+      }
+      $color = "darkgreen";
+      if($d["total"] >= 70 && $d["total"] < 90) {
+        $color = "darkgray";
+      } elseif($d["total"] < 70) {
+        $color = "red";
+      }
+      $descargas[$d['pc']][$d['clave']][$d['fecha']] = [
+        "descargados" => $d['descargados'],
+        "pendientes" => $d['pendientes'],
+        "total" => $d['total'],
+        "color" => $color
+      ];
+    }
+
+    if($json) {
+      \Yii::$app->getResponse()->format = \yii\web\Response::FORMAT_JSON;
+      return [
+        "primer" => $primer,
+        "ultimo" => $ultimo,
+        "estaciones" => $estaciones,
+        "descargas" => $descargas
+      ];
+    }
+
+    return $this->render('index', [
+      "estaciones" => $estaciones,
+      "descargas" => $descargas,
+      "primer" => $primer,
+      "ultimo" => $ultimo
+    ]);
+  }
+
+}

+ 3 - 3
views/inicio/index.php

@@ -1,7 +1,7 @@
 <style>
   .site-card {
-    height: 100vh;
-    width: 100vw;
+    min-height: 100vh;
+    width: 100%;
     padding: 20px;
     background: #ececec;
   }
@@ -24,7 +24,7 @@
       <div className="site-card">
         <Card>
           <a href="/site/consulta">
-            <Card.Grid className="grid">Consultas</Card.Grid>
+            <Card.Grid className="grid">Consulta de Descarga</Card.Grid>
           </a>
           <a href="/site/asignar-descarga">
             <Card.Grid className="grid">Asignar Descarga</Card.Grid>

+ 70 - 0
views/reporte/index.php

@@ -0,0 +1,70 @@
+<?php
+
+/* @var $descargas app\models\Descarga[] */
+/* @var $estaciones array */
+/* @var $primer \DateTime */
+/* @var $ultimo \DateTime */
+
+?>
+<style>
+  .site-card {
+    min-height: 100vh;
+    width: 100vw;
+    padding: 20px;
+    background: #ececec;
+  }
+
+  .content {
+    width: 100%;
+    height: 100%;
+  }
+
+  .full-width {
+    width: 100%;
+  }
+</style>
+<div>
+  <table border="1" width="100%" id="tabla">
+    <tr>
+      <th>pc</th>
+      <th>ciudad</th>
+      <th>clave</th>
+      <th>siglas</th>
+      <th>frecuencia</th>
+      <?php $f = (clone $primer); ?>
+      <?php while($f <= $ultimo): ?>
+        <th>
+        <?= $f->format("d/m/Y") ?>
+        </th>
+        <?php $f->add(new \DateInterval("P1D")); ?>
+      <?php endwhile; ?>
+    </tr>
+    <?php $estacion = ""; ?>
+    <?php foreach ($estaciones as $pc => $est): ?>
+      <?php foreach($est as $clave => $info): ?>
+        <tr>
+          <td><?= $pc ?></td>
+          <td><?= $info['ciudad'] ?></td>
+          <td><?= $clave ?></td>
+          <td><?= $info['siglas'] ?></td>
+          <td><?= $info['frecuencia'] ?></td>
+          <?php $fecha = (clone $primer); ?>
+          <?php while($fecha <= $ultimo): ?>
+            <?php $d = null; ?>
+            <?php if(isset($descargas[$pc][$clave][$fecha->format("Y-m-d")])): ?>
+              <?php $d = $descargas[$pc][$clave][$fecha->format("Y-m-d")]; ?>
+            <?php endif; ?>
+            <?php if($d !== null): ?>
+              <td style="background-color: <?= $d["color"] ?>; text-align: center ">
+              <?= $d["descargados"] ?> / <?= $d["total"] ?>
+              </td>
+            <?php else: ?>
+              <td></td>
+            <?php endif; ?>
+            <?php $fecha->add(new \DateInterval("P1D")); ?>
+          <?php endwhile ?>
+        </tr>
+      <?php endforeach ?>
+    <?php endforeach ?>
+  </table>
+</div>

+ 18 - 14
views/site/asignar-descarga.php

@@ -1,7 +1,7 @@
 <style>
   .site-card {
     min-height: 100vh;
-    width: 100vw;
+    width: 100%;
     padding: 20px;
     background: #ececec;
   }
@@ -13,6 +13,11 @@
   .full-width {
     width: 100%;
   }
+  .codigo {
+    width: 50%;
+    height: 500px;
+    background: #fff;
+  }
 </style>
 <script type="text/babel">
   const url = "https://api.fourier.audio";
@@ -107,9 +112,8 @@
       });
 
       setDebug(cuerpo);
-
-      // form.setFieldsValue({ idPc: '' });
-      // setData([]);
+      form.setFieldsValue({ idPc: '' });
+      setData([]);
     }
 
     const agregarEstacion = () => {
@@ -203,7 +207,7 @@
                 onFinish={confirmar}
                 >
                 <Row gutter={8}>
-                  <Col span={6}>
+                  <Col md={8}>
                     <Form.Item
                       label="ID PC"
                       name="idPc"
@@ -212,7 +216,7 @@
                       <Input size="large" />
                     </Form.Item>
                   </Col>
-                  <Col span={6}>
+                  <Col md={8}>
                     <Form.Item
                       label="Rango de Fechas"
                       name="fechas"
@@ -228,7 +232,7 @@
                         />
                     </Form.Item>
                   </Col>
-                  <Col span={6}>
+                  <Col md={8}>
                     <Form.Item
                       label="&nbsp;"
                       name="reiniciar"
@@ -240,7 +244,7 @@
                   </Col>
                 </Row>
                 <Row gutter={8}>
-                  <Col span={6}>
+                  <Col md={8}>
                     <Form.Item
                       label="Ciudad"
                       name="idCiudad"
@@ -260,7 +264,7 @@
                       </Select>
                     </Form.Item>
                   </Col>
-                  <Col span={6}>
+                  <Col md={8}>
                     <Form.Item
                       label="Estación"
                       name="idEstacion"
@@ -281,22 +285,22 @@
                       </Select>
                     </Form.Item>
                   </Col>
-                  <Col span={3}>
+                  <Col md={3}>
                     <Form.Item label="&nbsp;" >
                       <Button className="full-width" size="large" onClick={agregarEstacion}>Agregar</Button>
                     </Form.Item>
                   </Col>
                 </Row>
                 <Row gutter={8}>
-                  <Col span={12}>
+                  <Col md={16}>
                     <Table className="full-width" dataSource={data} columns={columnas} />
                   </Col>
-                  <Col span={3}>
+                  <Col md={3}>
                     <Button className="full-width" size="large" onClick={obtenerEstacionDelPC}>Estaciones del PC</Button>
                   </Col>
                 </Row>
                 <Row>
-                  <Col span={6}>
+                  <Col md={8}>
                     <Form.Item label="&nbsp;" >
                       <Button type="primary" htmlType="submit" size="large" style={{width: '100%'}}>Guardar</Button>
                     </Form.Item>
@@ -305,7 +309,7 @@
               </Form>
               <Row>
                 <Col className="full-width">
-                  {debug && <pre className="full-width">{JSON.stringify(debug)}</pre>}
+                  {debug && <pre className="codigo"><code>{JSON.stringify(debug)}</code></pre>}
                 </Col>
               </Row>
             </Card>

+ 3 - 4
views/site/consulta.php

@@ -2,14 +2,13 @@
 
 <style>
   .site-card {
-    height: 100vh;
-    width: 100vw;
+    min-height: 100vh;
+    width: 100%;
     padding: 20px;
     background: #ececec;
   }
   .content {
     width: 100%;
-    height: 100%;
   }
   .grid {
     width: 25%;
@@ -35,7 +34,7 @@
     const onFinish = async (data) => {
       setCargando(true);
       const idPc = data.idPc;
-      const estacion = data.estacion;
+      const estacion = data.estacion || "";
       const fi = data.fechas[0].format("YYYY-MM-DD HH:mm:ss");
       const ff = data.fechas[1].format("YYYY-MM-DD HH:mm:ss");