소스 검색

Added externalID and name of client in ONU list export. Ref #16

Maximiliano Schvindt 6 년 전
부모
커밋
3155c97628
3개의 변경된 파일112개의 추가작업 그리고 6개의 파일을 삭제
  1. 74 0
      src/FTTHBundle/Admin/ONUAdmin.php
  2. 19 6
      src/FTTHBundle/Entity/ONU.php
  3. 19 0
      src/FTTHBundle/Resources/translations/FTTHBundle.es.yml

+ 74 - 0
src/FTTHBundle/Admin/ONUAdmin.php

@@ -712,4 +712,78 @@ class ONUAdmin extends WorkflowBaseAdmin
         }
 
     }
+
+    public function getExportFields()
+    {
+
+        $fields = array();
+        $fields[$this->trans('export.ponSerialNumberAux')] = "ponSerialNumberAux";
+        $fields[$this->trans('export.serialNumber')] = "serialNumber";
+        $fields[$this->trans('export.currentState')] = "currentState";
+        $fields[$this->trans('export.clientId')] = "clientId";
+        $fields[$this->trans('export.clientExternalId')] = "clientExternalId";
+        $fields[$this->trans('export.ip')] = "ip";
+        $fields[$this->trans('export.mac')] = "mac";
+        $fields[$this->trans('export.radiusAuth')] = "radiusAuth";
+        $fields[$this->trans('export.olt')] = "olt";
+        $fields[$this->trans('export.nap')] = "nap";
+        $fields[$this->trans('export.slot')] = "slot";
+        $fields[$this->trans('export.link')] = "link";
+        $fields[$this->trans('export.position')] = "position";
+        $fields[$this->trans('export.catv')] = "catv";
+        $fields[$this->trans('export.activationCode')] = "activationCode";
+        $fields[$this->trans('export.created')] = "created";
+        $fields[$this->trans('export.updated')] = "updated";
+        
+        return $fields;
+    }
+
+    // Replace clientId to Client Name and set Client External ID
+    public function getDataSourceIterator()
+    {
+        $datagrid = $this->getDatagrid();
+        $datagrid->buildPager();
+
+        $clients = $this->getClients($datagrid);
+
+        foreach ($datagrid->getResults() as $order) {
+            $clientId = $order->getClientId();
+            if(isset($clients[$clientId])) {
+                $order->setClientExternalId($clients[$clientId]['externalId']);
+                $order->setClientId($clients[$clientId]['name']);
+            }
+        }
+
+        $datasourceit = $this->getModelManager()->getDataSourceIterator($datagrid, $this->getExportFields());
+
+        return $datasourceit;
+    }
+
+    // Get all clientsIDs and get data from api/clients.json in base
+    private function getClients($datagrid)
+    {
+        $container = $this->getConfigurationPool()->getContainer();
+        $clientsIds = array();
+        foreach($datagrid->getResults() as $object) {
+            if($object->getClientId())
+                $clientsIds[$object->getClientId()] = $object->getClientId();
+        }
+
+        $_clients = array();
+        
+        if ($container->hasParameter('client') && $clientsIds) {
+            $clientApi = $this->getParameter('client');
+            $webservice = $this->get("webservice");
+            $filters = array("qb-ids" => implode(",",$clientsIds), 'qb-criteria' => true);
+            $clients = $webservice->getData($clientApi, $filters);
+            
+            if (is_array($clients) && !empty($clients)) {
+                foreach ($clients as $client) 
+                    $_clients[$client['id']] = array('name' => $client['name'], 'externalId' => $client['externalId']);
+                
+            }
+        }
+
+        return $_clients;
+    }
 }

+ 19 - 6
src/FTTHBundle/Entity/ONU.php

@@ -107,6 +107,9 @@ class ONU implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
      */
     private $clientId;
 
+    // Used in ONU Admin and established the value on the fly - Don't save it in DB
+    private $clientExternalId;
+
     /**
      * @ORM\Column(type="datetime")
      *
@@ -650,12 +653,12 @@ class ONU implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
      */
     public function getSlot()
     {
-        $olt = null;
+        $slot = null;
         if ($this->nap) {
-            $olt = $this->nap->getSlot();
+            $slot = $this->nap->getSlot();
         }
 
-        return $olt;
+        return $slot;
     }
 
     /**
@@ -663,12 +666,12 @@ class ONU implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
      */
     public function getLink()
     {
-        $olt = null;
+        $link = null;
         if ($this->nap) {
-            $olt = $this->nap->getLink();
+            $link = $this->nap->getLink();
         }
 
-        return $olt;
+        return $link;
     }
 
     /**
@@ -1182,4 +1185,14 @@ class ONU implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
     {
         return $this->radiusAuth;
     }
+
+    public function getClientExternalId() 
+    {
+        return $this->clientExternalId;
+    }
+    
+    public function setClientExternalId($clientExternalId) 
+    {
+        return $this->clientExternalId = $clientExternalId;
+    }
 }

+ 19 - 0
src/FTTHBundle/Resources/translations/FTTHBundle.es.yml

@@ -328,6 +328,25 @@ show:
     label_log_o_l_t_date: Fecha OLT
     label_log_o_l_t_directory: Directorio log OLT
     label_date: Fecha
+
+export:
+    serialNumber: Serial Number
+    ponSerialNumberAux: Pon Serial Number
+    currentState: Estado
+    clientId: Nombre Cliente
+    clientExternalId: External ID Cliente
+    ip:  IP
+    mac: MAC
+    radiusAuth: Validación Radius
+    olt: OLT
+    nap: NAP
+    slot: SLOT
+    link: LINK
+    position: Position
+    catv: CATV
+    activationCode: Código de Activación
+    created: Creada
+    updated: Actualizada
     
 helps:
     check_address: Verifique la dirección para el cálculo de distancias.