Browse Source

FD3-643 template en perfil de ftth

Espinoza Guillermo 6 năm trước cách đây
mục cha
commit
8e349f8822

+ 18 - 2
src/FTTHBundle/Admin/ProfileAdmin.php

@@ -8,6 +8,7 @@ use Sonata\AdminBundle\Datagrid\DatagridMapper;
 use Sonata\AdminBundle\Datagrid\ListMapper;
 use Sonata\AdminBundle\Form\FormMapper;
 use Sonata\AdminBundle\Show\ShowMapper;
+use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
 
 class ProfileAdmin extends BaseAdmin
 {
@@ -31,6 +32,7 @@ class ProfileAdmin extends BaseAdmin
             ->add('name')
             ->add('upload')
             ->add('download')
+            ->add('template')
             ->add('extraData')
             ->add('_action', null, array(
                 'actions' => array(
@@ -46,11 +48,23 @@ class ProfileAdmin extends BaseAdmin
      */
     protected function configureFormFields(FormMapper $formMapper)
     {
+        $templates = [
+            'template_radius.tpl',
+        ];
+        
         $formMapper
             ->add('name')
             ->add('upload')
             ->add('download')
-            ->add('extraData');
+            ->add('template', ChoiceType::class, [
+                'required' => false,
+                'choices' => array_combine($templates, $templates),
+                'preferred_choices' => [
+                    'template_radius.tpl',
+                ],
+            ])
+            ->add('extraData')
+            ;
     }
 
     /**
@@ -62,7 +76,9 @@ class ProfileAdmin extends BaseAdmin
             ->add('name')
             ->add('upload')
             ->add('download')
-            ->add('extraData');
+            ->add('template')
+            ->add('extraData')
+            ;
     }
 
 }

+ 53 - 4
src/FTTHBundle/Entity/Profile.php

@@ -56,6 +56,13 @@ class Profile implements TenancyIdTraitInterface
      * @JMS\Exclude
      */
     protected $onus;
+    
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", nullable=true)
+     */
+    protected $template;
 
 
     /**
@@ -146,11 +153,30 @@ class Profile implements TenancyIdTraitInterface
         return $this->download;
     }
 
+    /**
+     * @return string
+     */
+    public function getDownloadAsK()
+    {
+        return round($this->getDownload() / 1000, 2) . "k";
+    }
+    
+    /**
+     * @return string
+     */
+    public function getUploadAsK()
+    {
+        return round($this->getUpload() / 1000, 2) . "k";
+    }
 
-    function getDownloadAsK(){return round($this->getDownload()/1000,2)."k"; }
-    function getUploadAsK()  {return round($this->getUpload()/1000,2)."k"; }
-
-    function getRadiusName()  {return preg_replace("|[^A-Za-z0-9]|", "-", $this->name); }
+    /**
+     * @return string
+     */
+    public function getRadiusName()
+    {
+        return preg_replace("|[^A-Za-z0-9]|", "-", $this->name);
+    }
+    
     /**
      * Constructor
      */
@@ -181,5 +207,28 @@ class Profile implements TenancyIdTraitInterface
     public function removeOnus(\FTTHBundle\Entity\ONU $onus)
     {
         $this->onus->removeElement($onus);
+        
+        return $this;
+    }
+    
+    /**
+     * @return string
+     */
+    public function getTemplate()
+    {
+        return $this->template;
+    }
+    
+    /**
+     * @param string $template
+     *
+     * @return Profile
+     */
+    public function setTemplate($template)
+    {
+        $this->template = $template;
+        
+        return $this;
     }
+    
 }

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

@@ -53,6 +53,7 @@ filter:
     label_capacity: Capacidad
     label_value: Valor
     label_comments: Comentarios
+    label_template: Template
 
 breadcrumb:
     link_t_cont_profile_list: Listado Perfiles tcon
@@ -154,6 +155,7 @@ form:
     label_vlans: VLans
     label_comments: Comentarios
     label_activation_code: Código Activación
+    label_template: Template
 
 list:
     label_id: Id
@@ -215,6 +217,7 @@ list:
     label_base: Base
     label_comments: Comentarios
     label_activation_code: Código Activación
+    label_template: Template
 
 show:
     label_id: Id
@@ -278,6 +281,7 @@ show:
     label_used_by_default: Default
     label_comments: Comentarios
     label_activation_code: Código Activación
+    label_template: Template
 
 helps:
     check_address: Verifique la dirección para el cálculo de distancias.