فهرست منبع

Agregado filtro de estacion

Hugo 4 سال پیش
والد
کامیت
f0f445c9c9
2فایلهای تغییر یافته به همراه28 افزوده شده و 9 حذف شده
  1. 11 6
      controllers/DescargaController.php
  2. 17 3
      views/site/consulta.php

+ 11 - 6
controllers/DescargaController.php

@@ -31,6 +31,7 @@ class DescargaController extends JsonController {
     $pc = trim($req->get("pc", ""));
     $fi = trim($req->get("fi", ""));
     $ff = trim($req->get("ff", ""));
+    $estacion = trim($req->get("estacion", ""));
 
     $query = (new Query())
       ->select([
@@ -49,13 +50,17 @@ class DescargaController extends JsonController {
       ->groupBy(["{{Estacion}}.id", "to_char(fecha, 'YYYY-MM-DD')", "ciudad"])
       ->orderBy(["fecha" => SORT_DESC]);
 
-      if($fi !== "") {
-        $query->andWhere([">=", "fecha", $fi]);
-      }
+    if($estacion !== "") {
+      $query->andWhere(["estacion" => $estacion]);
+    }
 
-      if($ff !== "") {
-        $query->andWhere(["<=", "fecha", $ff]);
-      }
+    if($fi !== "") {
+      $query->andWhere([">=", "fecha", $fi]);
+    }
+
+    if($ff !== "") {
+      $query->andWhere(["<=", "fecha", $ff]);
+    }
 
     return (new Respuesta($query, -1));
   }

+ 17 - 3
views/site/consulta.php

@@ -35,10 +35,11 @@
     const onFinish = async (data) => {
       setCargando(true);
       const idPc = data.idPc;
+      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");
 
-      const resp = await fetch(`${url}/descarga/por-pc?pc=${idPc}&fi=${fi}&ff=${ff}`);
+      const resp = await fetch(`${url}/descarga/por-pc?pc=${idPc}&fi=${fi}&ff=${ff}&estacion=${estacion}`);
       const res = await resp.json();
 
       setDescargas(res.resultado);
@@ -96,7 +97,16 @@
                   name="idPc"
                   rules={[{ required: true, message: 'Ingresa el ID del PC' }]}
                 >
-                  <Input size="large" />
+                  <Input placeholder="ID del anydesk" size="large" />
+                </Form.Item>
+              </Col>
+              <Col span={6}>
+                <Form.Item
+                  label="Estación"
+                  name="estacion"
+                  rules={[{ required: false }]}
+                >
+                  <Input placeholder="Clave de la Estación (opcional)" size="large" />
                 </Form.Item>
               </Col>
               <Col span={6}>
@@ -122,8 +132,12 @@
               </Col>
             </Row>
           </Form>
+          { cargando && <Row>
+            <Col>
+              <LoadingOutlined style={{ fontSize: 24 }} spin />
+            </Col>
+          </Row>}
           <Row>
-            { cargando && <LoadingOutlined style={{ fontSize: 24 }} spin />}
             <Col span={16}>
               <Table className="full-width" dataSource={descargas} columns={columnas} />
             </Col>