|
@@ -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;
|
|
|
+ }
|
|
|
}
|