|
@@ -27,32 +27,46 @@ class ONUController extends Controller
|
|
|
|
|
|
public function importAction()
|
|
|
{
|
|
|
- //$em = $this->get('doctrine')->getManager();
|
|
|
$adminPool = $this->get('sonata.admin.pool');
|
|
|
$webservice = $this->get("webservice");
|
|
|
+ $translator = $this->get('translator');
|
|
|
+ $flashbag = $this->get('session')->getFlashBag();
|
|
|
|
|
|
- $urlMaps = $this->getParameter('remote_get_map_url');
|
|
|
-
|
|
|
- /* Chequeamos que existe el objectType ONU - Esto debe venir definido por defecto luego */
|
|
|
- $urlObjectTypes = $this->getParameter('remote_get_object_type_url');
|
|
|
- $filters = array('name' => 'ONU');
|
|
|
- $_types = $webservice->getData($urlObjectTypes, $filters, array(), null, null);
|
|
|
+ $urlObjects = $this->container->hasParameter('remote_get_objects_url');
|
|
|
+ $urlObjectTypes = $this->container->hasParameter('remote_get_object_type_url');
|
|
|
+ $_types = array();
|
|
|
$disabled = false;
|
|
|
- $flashbag = $this->get('session')->getFlashBag();
|
|
|
- if(empty($_types)) {
|
|
|
- $flashbag->add("error", "No existen ONUs definidas en el módulo de Mapas.");
|
|
|
+ $objectTypeId = 0;
|
|
|
+
|
|
|
+ if(!$urlObjects) {
|
|
|
+ $flashbag->add("error", $translator->trans("msg_no_defined_ftth_url",array(),"FTTHBundle"));
|
|
|
$disabled = true;
|
|
|
- $objectTypeId = 0;
|
|
|
} else {
|
|
|
- $objectTypeId = $_types[0]['id'];
|
|
|
+ if(!$urlObjectTypes) {
|
|
|
+ $flashbag->add("error", $translator->trans("msg_no_defined_ftth_url",array(),"FTTHBundle"));
|
|
|
+ $disabled = true;
|
|
|
+ } else {
|
|
|
+ $urlObjectTypes = $this->getParameter('remote_get_object_type_url');
|
|
|
+ $filters = array('name' => 'ONU');
|
|
|
+ $_types = $webservice->getData($urlObjectTypes, $filters, array(), null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($_types)) {
|
|
|
+ $flashbag->add("error", $translator->trans("msg_no_onu_in_map",array(),"FTTHBundle"));
|
|
|
+ $disabled = true;
|
|
|
+ $objectTypeId = 0;
|
|
|
+ } else {
|
|
|
+ $disabled = false;
|
|
|
+ $objectTypeId = $_types[0]['id'];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$form = $this->createFormBuilder()
|
|
|
- ->add('mapId', RemoteMapType::class, array('label' => 'Mapa', 'disabled' => $disabled))
|
|
|
- ->add('clientId', RemoteClientType::class, array('label' => 'Cliente', 'disabled' => $disabled))
|
|
|
+ ->add('mapId', RemoteMapType::class, array('label' => $translator->trans("form.label_map",array(),"FTTHBundle"), 'disabled' => $disabled))
|
|
|
+ ->add('clientId', RemoteClientType::class, array('label' => $translator->trans("form.label_client",array(),"FTTHBundle"), 'disabled' => $disabled))
|
|
|
->getForm();
|
|
|
|
|
|
- $flashbag->add("warning", "Seleccione el Mapa desde el que se importarán las ONUs y el cliente al que se asociarán.");
|
|
|
+ $flashbag->add("warning", $translator->trans("msg_select_map",array(),"FTTHBundle"));
|
|
|
|
|
|
return $this->render('FTTHBundle:ONU:onu_import.html.twig', array(
|
|
|
'base_template' => $adminPool->getTemplate('layout'),
|