浏览代码

Merge remote-tracking branch 'origin/FD3-643'

Luciano Andrade 6 年之前
父节点
当前提交
5e76dc8c37

文件差异内容过多而无法显示
+ 2 - 2
app/DoctrineMigrations/src/action.yml


+ 1 - 0
app/DoctrineMigrations/src/profile.yml

@@ -6,3 +6,4 @@ insertorupdate:
           upload: 1024000
           download: 3072000
           tenancy_id: 1
+          template: "template_radius.tpl"

文件差异内容过多而无法显示
+ 5 - 1
app/DoctrineMigrations/src/template.yml


+ 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')
+            ;
     }
 
 }

+ 58 - 8
src/FTTHBundle/Entity/Profile.php

@@ -56,8 +56,24 @@ class Profile implements TenancyIdTraitInterface
      * @JMS\Exclude
      */
     protected $onus;
+    
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", nullable=true)
+     */
+    protected $template;
 
 
+    /**
+     * Constructor
+     */
+    public function __construct()
+    {
+        $this->onus = new \Doctrine\Common\Collections\ArrayCollection();
+        $this->template = 'template_radius.tpl';
+    }
+    
     /**
      * @return string
      */
@@ -146,19 +162,30 @@ class Profile implements TenancyIdTraitInterface
         return $this->download;
     }
 
-
-    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); }
     /**
-     * Constructor
+     * @return string
      */
-    public function __construct()
+    public function getDownloadAsK()
     {
-        $this->onus = new \Doctrine\Common\Collections\ArrayCollection();
+        return round($this->getDownload() / 1000, 2) . "k";
+    }
+    
+    /**
+     * @return string
+     */
+    public function getUploadAsK()
+    {
+        return round($this->getUpload() / 1000, 2) . "k";
     }
 
+    /**
+     * @return string
+     */
+    public function getRadiusName()
+    {
+        return preg_replace("|[^A-Za-z0-9]|", "-", $this->name);
+    }
+    
     /**
      * Add onus
      *
@@ -181,5 +208,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.