|
@@ -15,6 +15,8 @@ use Sonata\CoreBundle\Validator\ErrorElement;
|
|
|
|
|
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
|
|
use FTTHBundle\Form\ServicePortType;
|
|
|
+use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
|
|
+use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
|
|
|
|
|
|
|
|
class ONUAdmin extends WorkflowBaseAdmin
|
|
@@ -69,30 +71,31 @@ class ONUAdmin extends WorkflowBaseAdmin
|
|
|
*/
|
|
|
protected function configureFormFields(FormMapper $formMapper)
|
|
|
{
|
|
|
+
|
|
|
$formMapper
|
|
|
->tab('default')
|
|
|
- ->with('')
|
|
|
- ->add('clientId')
|
|
|
- ->add('ponSerialNumber', null, array('attr' => array('style' => 'text-transform: uppercase;')))
|
|
|
- ->add('profile')
|
|
|
- ->add('nap')
|
|
|
- ->add('model')
|
|
|
- ->end()
|
|
|
+ ->with('')
|
|
|
+ ->add('clientId')
|
|
|
+ ->add('ponSerialNumber', null, array('attr' => array('style' => 'text-transform: uppercase;')))
|
|
|
+ ->add('profile')
|
|
|
+ ->add('nap')
|
|
|
+ ->add('model')
|
|
|
+ ->end()
|
|
|
->end()
|
|
|
->tab('Avanzado')
|
|
|
- ->with('ONU')
|
|
|
- ->add('serialNumber', null, array('attr' => array('style' => 'text-transform: uppercase;')))
|
|
|
- ->add('ponSerialNumberAux', null, array('attr' => array('style' => 'text-transform: uppercase;')))
|
|
|
- ->add('mac')
|
|
|
- ->add('olt')
|
|
|
- ->add('position')
|
|
|
- ->add('service_port',CollectionType::class, array(
|
|
|
- 'entry_type' => "FTTHBundle\\Form\\ServicePortType",
|
|
|
- 'allow_add' => true,
|
|
|
- 'allow_delete' => true,
|
|
|
- 'required' => false,
|
|
|
- ))
|
|
|
- ->end()
|
|
|
+ ->with('ONU')
|
|
|
+ ->add('serialNumber', null, array('attr' => array('style' => 'text-transform: uppercase;')))
|
|
|
+ ->add('ponSerialNumberAux', null, array('attr' => array('style' => 'text-transform: uppercase;')))
|
|
|
+ ->add('mac')
|
|
|
+ ->add('olt')
|
|
|
+ ->add('position')
|
|
|
+ ->add('service_port',CollectionType::class, array(
|
|
|
+ 'entry_type' => "FTTHBundle\\Form\\ServicePortType",
|
|
|
+ 'allow_add' => true,
|
|
|
+ 'allow_delete' => true,
|
|
|
+ 'required' => false,
|
|
|
+ ))
|
|
|
+ ->end()
|
|
|
->end()
|
|
|
->setHelps(array(
|
|
|
'nap' => $this->trans("helps.check_address"),
|
|
@@ -103,6 +106,94 @@ class ONUAdmin extends WorkflowBaseAdmin
|
|
|
));
|
|
|
|
|
|
|
|
|
+
|
|
|
+ $tr069Data = 0;
|
|
|
+
|
|
|
+ if($this->isCurrentRoute('edit')) {
|
|
|
+
|
|
|
+ if($this->getParameter('tr069_service')) {
|
|
|
+ $object = $this->getSubject();
|
|
|
+
|
|
|
+ $query = array('$or' => array());
|
|
|
+ if($object->getSerialNumber()) {
|
|
|
+ $query['$or'][] = array("InternetGatewayDevice.DeviceInfo.SerialNumber" => strtoupper($object->getSerialNumber()));
|
|
|
+ $query['$or'][] = array("InternetGatewayDevice.DeviceInfo.SerialNumber" => strtolower($object->getSerialNumber()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if($object->getPonSerialNumber()) {
|
|
|
+ $query['$or'][] = array("InternetGatewayDevice.DeviceInfo.SerialNumber" => strtoupper($object->getPonSerialNumber()));
|
|
|
+ $query['$or'][] = array("InternetGatewayDevice.DeviceInfo.SerialNumber" => strtolower($object->getPonSerialNumber()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if($object->getPonSerialNumberAux()) {
|
|
|
+ $query['$or'][] = array("InternetGatewayDevice.DeviceInfo.SerialNumber" => strtoupper($object->getPonSerialNumberAux()));
|
|
|
+ $query['$or'][] = array("InternetGatewayDevice.DeviceInfo.SerialNumber" => strtolower($object->getPonSerialNumberAux()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $devices = $this->get('tr069.api')->getDevices($query);
|
|
|
+
|
|
|
+ if(is_array($devices) && isset($devices[0]) && isset($devices[0]['_id'])) {
|
|
|
+
|
|
|
+ $tr069Data = $this->getTR069Data($devices[0]);
|
|
|
+
|
|
|
+ $id = $tr069Data['_id'] ?? null;
|
|
|
+ $manufacturer = $tr069Data['_deviceId']['_Manufacturer'] ?? null;
|
|
|
+ $oui = $tr069Data['_deviceId']['_OUI'] ?? null;
|
|
|
+ $productClass = $tr069Data['_deviceId']['_ProductClass'] ?? null;
|
|
|
+ $serialNumber = $tr069Data['_deviceId']['_SerialNumber'] ?? null;
|
|
|
+ $ip = $tr069Data['ExternalIPAddress']['_value'] ?? null;
|
|
|
+
|
|
|
+ $ssid = $tr069Data['SSID']['_value'] ?? null;
|
|
|
+ $pass = $tr069Data['preSharedKey']['_value'] ?? null;
|
|
|
+ $broadcast = $tr069Data['SSIDAdvertisementEnabled']['_value'] ?? null;
|
|
|
+ $status = $tr069Data['Status']['_value'] ?? null;
|
|
|
+
|
|
|
+ $catv = $tr069Data['CatvPower']['_value'] ?? null;
|
|
|
+
|
|
|
+ $ip = $tr069Data['ExternalIPAddress']['_value'] ?? null;
|
|
|
+
|
|
|
+ $formMapper
|
|
|
+ ->tab('TR069')
|
|
|
+ ->with('General')
|
|
|
+ ->add('tr069_id', 'text', array('mapped' => false, 'data' => $id, 'required' => false, 'disabled' => true))
|
|
|
+ ->add('tr069_manufacturer', 'text', array('mapped' => false, 'data' => $manufacturer, 'required' => false, 'disabled' => true))
|
|
|
+ ->add('tr069_oui', 'text', array('mapped' => false, 'data' => $oui, 'required' => false, 'disabled' => true))
|
|
|
+ ->add('tr069_product_class', 'text', array('mapped' => false, 'data' => $productClass, 'required' => false, 'disabled' => true))
|
|
|
+ ->add('tr069_serial_number', 'text', array('mapped' => false, 'data' => $serialNumber, 'required' => false, 'disabled' => true))
|
|
|
+ ->add('tr069_ip', 'text', array('mapped' => false, 'data' => $ip, 'required' => false, 'disabled' => true))
|
|
|
+ ->end()
|
|
|
+ ->with('WIFI',['description' => $this->trans('helps.tr069_wifi')])
|
|
|
+ ->add('tr069_ssid', 'text', array('mapped' => false, 'data' => $ssid, 'required' => false))
|
|
|
+ ->add('tr069_pass', 'text', array('mapped' => false, 'data' => $pass, 'required' => false))
|
|
|
+ ->add('tr069_broadcast', CheckboxType::class, array('mapped' => false, 'data' => $broadcast, 'required' => false))
|
|
|
+ ->add('tr069_status', CheckboxType::class, array('mapped' => false, 'data' => $status, 'required' => false))
|
|
|
+ ->end()
|
|
|
+ ->with('CATV',['description' => $this->trans('helps.tr069_catv')])
|
|
|
+ ->add('tr069_catv', CheckboxType::class, array('mapped' => false, 'data' => $catv, 'required' => false))
|
|
|
+ ->end()
|
|
|
+ ->end();
|
|
|
+
|
|
|
+ $tr069Data = 1;
|
|
|
+ } else {
|
|
|
+ $formMapper->tab('TR069')->with('General', ['description' => $this->trans('helps.tr069_onu_no_detected')])->end()->end();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $formMapper->tab('TR069')->with('General', ['description' => $this->trans('helps.tr069_disabled')])->end()->end();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $formMapper->tab('TR069')->with('General', ['description' => $this->trans('helps.tr069_no_edit')])->end()->end();
|
|
|
+ }
|
|
|
+
|
|
|
+ // If use tr069 > send data in preUpdate()
|
|
|
+ $formMapper
|
|
|
+ ->tab('default')
|
|
|
+ ->with('')
|
|
|
+ ->add('tr069_exist', HiddenType::class, array('mapped' => false, 'data' => $tr069Data))
|
|
|
+ ->end()
|
|
|
+ ->end();
|
|
|
+
|
|
|
+
|
|
|
/*
|
|
|
* Si vienen parámetros por GET de olt=id o psn=string seteamos los campos
|
|
|
*/
|
|
@@ -139,32 +230,110 @@ class ONUAdmin extends WorkflowBaseAdmin
|
|
|
{
|
|
|
$showMapper
|
|
|
->tab('default')
|
|
|
- ->with('')
|
|
|
- ->add('clientId')
|
|
|
- ->add('ponSerialNumber')
|
|
|
- ->add('profile')
|
|
|
- ->add('nap')
|
|
|
- ->add('model')
|
|
|
- ->end()
|
|
|
+ ->with('')
|
|
|
+ ->add('clientId')
|
|
|
+ ->add('ponSerialNumber')
|
|
|
+ ->add('profile')
|
|
|
+ ->add('nap')
|
|
|
+ ->add('model')
|
|
|
+ ->end()
|
|
|
->end()
|
|
|
->tab('Avanzado')
|
|
|
- ->with('ONU')
|
|
|
- ->add('serialNumber')
|
|
|
- ->add('ponSerialNumberAux')
|
|
|
- ->add('mac')
|
|
|
- ->add('olt')
|
|
|
- ->add('currentState')
|
|
|
- ->end()
|
|
|
+ ->with('ONU')
|
|
|
+ ->add('serialNumber')
|
|
|
+ ->add('ponSerialNumberAux')
|
|
|
+ ->add('mac')
|
|
|
+ ->add('olt')
|
|
|
+ ->add('currentState')
|
|
|
+ ->end()
|
|
|
->end()
|
|
|
->tab('Log')
|
|
|
- ->with('Log')
|
|
|
- ->add('log', 'string', array('template' => 'FTTHBundle:ONU:show_log.html.twig'))
|
|
|
- ->add('deviceLog', 'string', array(
|
|
|
- 'template' => 'DeviceBundle::show_device_log.html.twig',
|
|
|
- 'translation_domain' => 'DeviceBundle',
|
|
|
- ))
|
|
|
- ->end()
|
|
|
+ ->with('Log')
|
|
|
+ ->add('log', 'string', array('template' => 'FTTHBundle:ONU:show_log.html.twig'))
|
|
|
+ ->add('deviceLog', 'string', array(
|
|
|
+ 'template' => 'DeviceBundle::show_device_log.html.twig',
|
|
|
+ 'translation_domain' => 'DeviceBundle',
|
|
|
+ ))
|
|
|
+ ->end()
|
|
|
->end();
|
|
|
+
|
|
|
+ if($this->getParameter('tr069_service')) {
|
|
|
+ $object = $this->getSubject();
|
|
|
+
|
|
|
+ $query = array('$or' => array());
|
|
|
+ if($object->getSerialNumber()) {
|
|
|
+ $query['$or'][] = array("InternetGatewayDevice.DeviceInfo.SerialNumber" => strtoupper($object->getSerialNumber()));
|
|
|
+ $query['$or'][] = array("InternetGatewayDevice.DeviceInfo.SerialNumber" => strtolower($object->getSerialNumber()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if($object->getPonSerialNumber()) {
|
|
|
+ $query['$or'][] = array("InternetGatewayDevice.DeviceInfo.SerialNumber" => strtoupper($object->getPonSerialNumber()));
|
|
|
+ $query['$or'][] = array("InternetGatewayDevice.DeviceInfo.SerialNumber" => strtolower($object->getPonSerialNumber()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if($object->getPonSerialNumberAux()) {
|
|
|
+ $query['$or'][] = array("InternetGatewayDevice.DeviceInfo.SerialNumber" => strtoupper($object->getPonSerialNumberAux()));
|
|
|
+ $query['$or'][] = array("InternetGatewayDevice.DeviceInfo.SerialNumber" => strtolower($object->getPonSerialNumberAux()));
|
|
|
+ }
|
|
|
+
|
|
|
+ $devices = $this->get('tr069.api')->getDevices($query);
|
|
|
+
|
|
|
+ if(is_array($devices) && isset($devices[0]) && isset($devices[0]['_id'])) {
|
|
|
+
|
|
|
+ $tr069Data = $this->getTR069Data($devices[0]);
|
|
|
+
|
|
|
+ $id = $tr069Data['_id'] ?? null;
|
|
|
+ $manufacturer = $tr069Data['_deviceId']['_Manufacturer'] ?? null;
|
|
|
+ $oui = $tr069Data['_deviceId']['_OUI'] ?? null;
|
|
|
+ $productClass = $tr069Data['_deviceId']['_ProductClass'] ?? null;
|
|
|
+ $serialNumber = $tr069Data['_deviceId']['_SerialNumber'] ?? null;
|
|
|
+ $ip = $tr069Data['ExternalIPAddress']['_value'] ?? null;
|
|
|
+
|
|
|
+ $ssid = $tr069Data['SSID']['_value'] ?? null;
|
|
|
+ $pass = $tr069Data['preSharedKey']['_value'] ?? null;
|
|
|
+ $broadcast = $tr069Data['SSIDAdvertisementEnabled']['_value'] ?? null;
|
|
|
+ $status = $tr069Data['Status']['_value'] ?? null;
|
|
|
+
|
|
|
+ $catv = $tr069Data['CatvPower']['_value'] ?? null;
|
|
|
+
|
|
|
+ $ip = $tr069Data['ExternalIPAddress']['_value'] ?? null;
|
|
|
+
|
|
|
+ $showMapper
|
|
|
+ ->tab('TR069')
|
|
|
+ ->with('General')
|
|
|
+ ->add('tr069_id', null, array('template' => 'FTTHBundle:ONU:base_show_text.html.twig', 'text' => $id))
|
|
|
+ ->add('tr069_manufacturer', null, array('template' => 'FTTHBundle:ONU:base_show_text.html.twig', 'text' => $manufacturer))
|
|
|
+ ->add('tr069_oui', null, array('template' => 'FTTHBundle:ONU:base_show_text.html.twig', 'text' => $oui))
|
|
|
+ ->add('tr069_product_class', null, array('template' => 'FTTHBundle:ONU:base_show_text.html.twig', 'text' => $productClass))
|
|
|
+ ->add('tr069_serial_number', null, array('template' => 'FTTHBundle:ONU:base_show_text.html.twig', 'text' => $serialNumber))
|
|
|
+ ->add('tr069_ip', null, array('template' => 'FTTHBundle:ONU:base_show_text.html.twig', 'text' => $ip))
|
|
|
+ ->end()
|
|
|
+ ->with('WIFI',['description' => $this->trans('helps.tr069_wifi')])
|
|
|
+ ->add('tr069_ssid', null, array('template' => 'FTTHBundle:ONU:base_show_text.html.twig', 'text' => $ssid))
|
|
|
+ ->add('tr069_pass', null, array('template' => 'FTTHBundle:ONU:base_show_text.html.twig', 'text' => $pass))
|
|
|
+ ->add('tr069_broadcast', null, array('template' => 'FTTHBundle:ONU:base_show_boolean.html.twig', 'boolean' => $broadcast))
|
|
|
+ ->add('tr069_status', null, array('template' => 'FTTHBundle:ONU:base_show_boolean.html.twig', 'boolean' => $status))
|
|
|
+ ->end()
|
|
|
+ ->with('CATV',['description' => $this->trans('helps.tr069_catv')])
|
|
|
+ ->add('tr069_catv', null, array('template' => 'FTTHBundle:ONU:base_show_boolean.html.twig', 'boolean' => $catv))
|
|
|
+ ->end()
|
|
|
+ ->end();
|
|
|
+ } else {
|
|
|
+ $showMapper
|
|
|
+ ->tab('TR069')
|
|
|
+ ->with('General')
|
|
|
+ ->add('tr069_id', null, array('template' => 'FTTHBundle:ONU:base_show_field.html.twig', 'text' => $this->trans('helps.tr069_onu_no_detected')))
|
|
|
+ ->end()
|
|
|
+ ->end();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $showMapper
|
|
|
+ ->tab('TR069')
|
|
|
+ ->with('General')
|
|
|
+ ->add('tr069_id', null, array('template' => 'FTTHBundle:ONU:base_show_field.html.twig', 'text' => $this->trans('helps.tr069_disabled')))
|
|
|
+ ->end()
|
|
|
+ ->end();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -193,6 +362,24 @@ class ONUAdmin extends WorkflowBaseAdmin
|
|
|
public function preUpdate($onu)
|
|
|
{
|
|
|
$this->correctSerialNumber($onu);
|
|
|
+
|
|
|
+ if((boolean) $this->getForm()->get('tr069_exist')->getData()) {
|
|
|
+ $ssid = ($this->getForm()->get('tr069_ssid')->getData()) ?? null;
|
|
|
+ $pass = ($this->getForm()->get('tr069_pass')->getData()) ?? null;
|
|
|
+ $id = ($this->getForm()->get('tr069_id')->getData()) ?? null;;
|
|
|
+ $catv = ($this->getForm()->get('tr069_catv')->getData()) ?? null;
|
|
|
+ $broadcast = ($this->getForm()->get('tr069_broadcast')->getData()) ?? null;
|
|
|
+ $status = ($this->getForm()->get('tr069_status')->getData()) ?? null;
|
|
|
+
|
|
|
+ if($ssid) $aux = $this->get('tr069.api')->setWlan($id, $ssid, $pass);
|
|
|
+
|
|
|
+ if(!is_null($catv)) $aux = $this->get('tr069.api')->setCATV($id, $catv);
|
|
|
+
|
|
|
+ if(!is_null($broadcast)) $aux = $this->get('tr069.api')->setWbroadcast($id, $broadcast);
|
|
|
+
|
|
|
+ if(!is_null($status)) $aux = $this->get('tr069.api')->setWstatus($id, $status);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public function prePersist($onu)
|
|
@@ -276,22 +463,47 @@ class ONUAdmin extends WorkflowBaseAdmin
|
|
|
}
|
|
|
|
|
|
public function update($object){
|
|
|
- $em = $this->getConfigurationPool()->getContainer()->get('doctrine.orm.entity_manager');
|
|
|
- $all = $em->getRepository(\FTTHBundle\Entity\ServicePort::class)->findBy(array("onu" => $object));
|
|
|
- foreach($all as $sp){
|
|
|
- if(!$object->getServicePort()->contains($sp)){
|
|
|
- $em->remove($sp);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- foreach($object->getServicePort() as $sp){
|
|
|
- $sp->setOnu($object);
|
|
|
- $em->persist($sp);
|
|
|
- if(!$sp->getOlt()){
|
|
|
- $sp->setOlt($object->getOlt());
|
|
|
- }
|
|
|
- }
|
|
|
- return parent::update($object);
|
|
|
+ $em = $this->getConfigurationPool()->getContainer()->get('doctrine.orm.entity_manager');
|
|
|
+ $all = $em->getRepository(\FTTHBundle\Entity\ServicePort::class)->findBy(array("onu" => $object));
|
|
|
+ foreach($all as $sp){
|
|
|
+ if(!$object->getServicePort()->contains($sp)){
|
|
|
+ $em->remove($sp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach($object->getServicePort() as $sp){
|
|
|
+ $sp->setOnu($object);
|
|
|
+ $em->persist($sp);
|
|
|
+ if(!$sp->getOlt()){
|
|
|
+ $sp->setOlt($object->getOlt());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return parent::update($object);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getTR069Data($data) {
|
|
|
+ $result = array();
|
|
|
+
|
|
|
+ $result['_id'] = $data['_id'] ?? null;
|
|
|
+ $result['_deviceId'] = $data['_deviceId'] ?? null;
|
|
|
+
|
|
|
+ $result['SSID'] = $data['InternetGatewayDevice']['LANDevice']['1']['WLANConfiguration']['1']['SSID'] ?? null;
|
|
|
+ $result['keyPassphrase'] = $data['InternetGatewayDevice']['LANDevice']['1']['WLANConfiguration']['1']['KeyPassphrase'] ?? null;
|
|
|
+ $result['SSIDAdvertisementEnabled'] = $data['InternetGatewayDevice']['LANDevice']['1']['WLANConfiguration']['1']['SSIDAdvertisementEnabled'] ?? null;
|
|
|
+ $result['Status'] = $data['InternetGatewayDevice']['LANDevice']['1']['WLANConfiguration']['1']['Enable'] ?? null;
|
|
|
+
|
|
|
+ //InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.PreSharedKey
|
|
|
+ $result['preSharedKey'] = $data['InternetGatewayDevice']['LANDevice']['1']['WLANConfiguration']['1']['PreSharedKey']['1']['PreSharedKey'] ?? null;
|
|
|
+
|
|
|
+ $result['CatvPower'] = $data['InternetGatewayDevice']['VS_AppCfg']['VsCatvCfg']['CatvPower'] ?? null;
|
|
|
+ $result['ExternalIPAddress'] = $data['InternetGatewayDevice']['WANDevice']['1']['WANConnectionDevice']['1']['WANPPPConnection']['1']['ExternalIPAddress'] ?? null;
|
|
|
+
|
|
|
+ return $result;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|