|
@@ -86,18 +86,26 @@ class ONUAdmin extends WorkflowBaseAdmin
|
|
|
protected function configureFormFields(FormMapper $formMapper)
|
|
|
{
|
|
|
$marks = OLTModelMark::getChoices();
|
|
|
- foreach ($marks as $m) {
|
|
|
- $hidden[$m] = 'hidden';
|
|
|
- }
|
|
|
+ $em = $this->get("doctrine.orm.entity_manager");
|
|
|
+ $template = $em->getRepository('FTTHBundle:ONUTemplate')->findOneBy(array('base'=>true));
|
|
|
$subject = $this->getSubject();
|
|
|
- if ($subject->getId()) {
|
|
|
- $olt = $subject->getOlt();
|
|
|
+
|
|
|
+ foreach ($marks as $m) {$hidden[$m] = 'hidden';}
|
|
|
+
|
|
|
+ if ($subject->getId() || $template) {
|
|
|
+ ($subject->getOlt())? $olt = $subject->getOlt() : $olt = $template->getOlt();
|
|
|
if ($olt && $olt->getModel()) {
|
|
|
$mark = $olt->getModel()->getMark();
|
|
|
$hidden[$mark] = '';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if($template && $this->isCurrentRoute('create')) {
|
|
|
+ $translator = $this->get('translator');
|
|
|
+ $flashbag = $this->get('session')->getFlashBag();
|
|
|
+ $flashbag->add("warning", $translator->trans("msg_use_template_onu_in_create_onu_ftth",array(),"FTTHBundle"));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
$formMapper
|
|
|
->tab('default')
|
|
@@ -136,6 +144,9 @@ class ONUAdmin extends WorkflowBaseAdmin
|
|
|
'multiple' => true,
|
|
|
))
|
|
|
->end()
|
|
|
+ ->with('Extra')
|
|
|
+ ->add('extraData')
|
|
|
+ ->end()
|
|
|
->end()
|
|
|
->setHelps(array(
|
|
|
'nap' => $this->trans("helps.check_address"),
|
|
@@ -242,12 +253,16 @@ class ONUAdmin extends WorkflowBaseAdmin
|
|
|
* Si vienen parámetros por GET de olt=id o psn=string seteamos los campos
|
|
|
*/
|
|
|
$formMapper->getFormBuilder()->addEventListener(FormEvents::PRE_SET_DATA,
|
|
|
- function (FormEvent $event) use ($formMapper) {
|
|
|
+ function (FormEvent $event) use ($formMapper, $template, $subject) {
|
|
|
$form = $event->getForm();
|
|
|
|
|
|
+ if($template && $this->isCurrentRoute('create')) {
|
|
|
+ $this->completeWithTemplate($form, $template);
|
|
|
+ }
|
|
|
+
|
|
|
$olt = $this->getRequest()->query->get('olt');
|
|
|
if(!is_null($olt)) {
|
|
|
- $em = $this->get("doctrine.orm.entity_manager");
|
|
|
+
|
|
|
$query_olt = $em->createQueryBuilder('o')
|
|
|
->select('o')
|
|
|
->from('FTTHBundle:OLT', 'o')
|
|
@@ -539,4 +554,56 @@ class ONUAdmin extends WorkflowBaseAdmin
|
|
|
return parent::update($object);
|
|
|
}
|
|
|
|
|
|
+ private function completeWithTemplate(&$form, $template){
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ if($client = $template->getClientId()) {
|
|
|
+ $form->add('clientId', null, array('data' => $client, 'label' => $this->trans("form.label_client")));
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
+ if($profile = $template->getProfile()) {
|
|
|
+ $form->add('profile', null, array('data' => $profile));
|
|
|
+ }
|
|
|
+
|
|
|
+ if($olt = $template->getOlt()) {
|
|
|
+ $form->add('olt', null, array('data' => $olt));
|
|
|
+ }
|
|
|
+
|
|
|
+ if($model = $template->getModel()) {
|
|
|
+ $form->add('model', null, array('data' => $model));
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ if($nap = $template->getNap()) {
|
|
|
+ $form->add('nap', null, array('data' => $nap));
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
+ if($vlan = $template->getVlan()) {
|
|
|
+ $form->add('vlan', null, array('data' => $vlan));
|
|
|
+ }
|
|
|
+
|
|
|
+ if($trafficProfile = $template->getTrafficProfile()) {
|
|
|
+ $form->add('traffic_profile', null, array('data' => $trafficProfile));
|
|
|
+ }
|
|
|
+
|
|
|
+ if($tcontprofile = $template->getTcontprofile()) {
|
|
|
+ $form->add('tcontprofile', null, array('data' => $tcontprofile));
|
|
|
+ }
|
|
|
+
|
|
|
+ if($vlans = $template->getVlans()) {
|
|
|
+ $form->add('vlans', null, array('data' => $vlans));
|
|
|
+ }
|
|
|
+
|
|
|
+ if($position = $template->getPosition()) {
|
|
|
+ $form->add('position', null, array('data' => $position));
|
|
|
+ }
|
|
|
+
|
|
|
+ if($extraData = $template->getExtraData()) {
|
|
|
+ $form->add('extraData', null, array('data' => $extraData));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|