Bladeren bron

#7 Captive portal presale entity and api

Espinoza Guillermo 6 jaren geleden
bovenliggende
commit
f031f23269

+ 1 - 0
app/config/config.yml

@@ -64,6 +64,7 @@ twig:
     form_themes:
         - 'WebserviceBundle:Type:remote_client_widget.html.twig'
         - 'FTTHBundle:Type:show_anchor.html.twig'
+        - '@SonataCore/Form/datepicker.html.twig'
     globals:
         base_url: "%url_base%"
         fd_alerts: '@base_admin.alert_service'

+ 5 - 0
app/config/roles.yml

@@ -87,6 +87,11 @@ security:
         ROLE_SONATA_ONUTEMPLATE_EDITOR: [ROLE_SONATA_ONUTEMPLATE_READER, ROLE_SONATA_ADMIN_ONUTEMPLATE_CREATE, ROLE_SONATA_ADMIN_ONUTEMPLATE_EDIT]
         ROLE_SONATA_ONUTEMPLATE_ADMIN: [ROLE_SONATA_ONUTEMPLATE_EDITOR, ROLE_SONATA_ADMIN_ONUTEMPLATE_DELETE, ROLE_SONATA_ADMIN_ONUTEMPLATE_EXPORT]
 
+        # PRESALE
+        ROLE_SONATA_PRESALE_READER: [ROLE_ADMIN, ROLE_SONATA_ADMIN_PRESALE_LIST, ROLE_SONATA_ADMIN_PRESALE_VIEW]
+        ROLE_SONATA_PRESALE_EDITOR: [ROLE_SONATA_PRESALE_READER, ROLE_SONATA_ADMIN_PRESALE_CREATE, ROLE_SONATA_ADMIN_PRESALE_EDIT]
+        ROLE_SONATA_PRESALE_ADMIN: [ROLE_SONATA_PRESALE_EDITOR, ROLE_SONATA_ADMIN_PRESALE_DELETE, ROLE_SONATA_ADMIN_PRESALE_EXPORT]
+
         ROLE_ADMIN_TENANCIES: ROLE_ADMIN_TENANCIES
         ROLE_ADMIN: [ROLE_USER, ROLE_SONATA_ADMIN]
         ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_USER_CREATE, ROLE_ADMIN_TENANCIES, ROLE_ALLOWED_TO_SWITCH]

+ 6 - 6
composer.lock

@@ -1947,7 +1947,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/BaseAdmin.git",
-                "reference": "a2b2110a69a21e2691266d66e421d2e56dff1c8a"
+                "reference": "fa71200c9b2fbad8f4b11ad414161bffb9e81811"
             },
             "type": "library",
             "autoload": {
@@ -1962,7 +1962,7 @@
                 "bootstrap",
                 "sonata"
             ],
-            "time": "2019-02-11T17:28:26+00:00"
+            "time": "2019-02-27T12:04:23+00:00"
         },
         {
             "name": "ik/check-sintax-bundle",
@@ -2083,7 +2083,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/migrations.git",
-                "reference": "f786c642a32803b11cda2514940d69bce81116ac"
+                "reference": "f28fb9789575889674e392a84e85a98d4b7dc0bb"
             },
             "type": "library",
             "autoload": {
@@ -2098,7 +2098,7 @@
                 "bundle",
                 "migrations"
             ],
-            "time": "2019-01-31T11:55:56+00:00"
+            "time": "2019-02-01T12:35:40+00:00"
         },
         {
             "name": "ik/oauthclient-bundle",
@@ -2202,7 +2202,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/Webservice.git",
-                "reference": "68f356b67da08b94cdb7613ad58c5525c88ff950"
+                "reference": "dcf83af721a56b40e4f521ebf53cc0918c7aa1f3"
             },
             "require": {
                 "ext-curl": "*",
@@ -2215,7 +2215,7 @@
                 }
             },
             "description": "The Flowdat3 Webservice Rest",
-            "time": "2019-01-31T13:36:09+00:00"
+            "time": "2019-02-27T12:06:15+00:00"
         },
         {
             "name": "ik/workflow-bundle",

+ 80 - 0
src/FTTHBundle/Admin/PreSaleAdmin.php

@@ -0,0 +1,80 @@
+<?php
+
+namespace FTTHBundle\Admin;
+
+use Base\AdminBundle\Admin\BaseAdmin;
+use Sonata\AdminBundle\Datagrid\DatagridMapper;
+use Sonata\AdminBundle\Datagrid\ListMapper;
+use Sonata\AdminBundle\Form\FormMapper;
+use Sonata\AdminBundle\Show\ShowMapper;
+use Sonata\CoreBundle\Form\Type\DatePickerType;
+use Symfony\Component\Form\Extension\Core\Type\TextareaType;
+
+class PreSaleAdmin extends BaseAdmin
+{
+
+    /**
+     * @param DatagridMapper $datagridMapper
+     */
+    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
+    {
+        $datagridMapper
+            ->add('clientId')
+            ->add('profile')
+            ->add('address')
+            ;
+    }
+
+    /**
+     * @param ListMapper $listMapper
+     */
+    protected function configureListFields(ListMapper $listMapper)
+    {
+        $listMapper
+            ->add('client', 'string', array(
+                'template' => 'FTTHBundle:ONU:base_list_field_client.html.twig'
+            ))
+            ->add('profile')
+            ->add('address')
+            ->add('date')
+            ->add('_action', null, array(
+                'actions' => array(
+                    'show' => array(),
+                    'edit' => array(),
+                    'delete' => array(),
+                )
+            ));
+    }
+
+    /**
+     * @param FormMapper $formMapper
+     */
+    protected function configureFormFields(FormMapper $formMapper)
+    {
+        $formMapper
+            ->add('clientId', null, [
+                'required' => true,
+            ])
+            ->add('profile')
+            ->add('address')
+            ->add('date', DatePickerType::class, [
+                'widget' => 'single_text',
+                'required' => false
+            ])
+        ;
+    }
+
+    /**
+     * @param ShowMapper $showMapper
+     */
+    protected function configureShowFields(ShowMapper $showMapper)
+    {
+        $showMapper
+            ->add('clientId')
+            ->add('profile')
+            ->add('address')
+            ->add('date')
+        ;
+    }
+
+}

+ 32 - 0
src/FTTHBundle/Controller/REST/PreSaleRESTController.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace FTTHBundle\Controller\REST;
+
+use FOS\RestBundle\Controller\Annotations\RouteResource;
+use FTTHBundle\Form\PreSaleType;
+use WebserviceBundle\Controller\RESTController;
+
+/**
+ * PreSale controller.
+ * @RouteResource("PreSale")
+ */
+class PreSaleRESTController extends RESTController
+{
+    
+    /**
+     * @return string Retorna el nombre de la Entity de trabajo.
+     */
+    public function getRepository()
+    {
+        return 'FTTHBundle:PreSale';
+    }
+
+    /**
+     * @return string Retorna el tipo de la clase.
+     */
+    public function getFormEntityType()
+    {
+        return get_class(new PreSaleType());
+    }
+    
+}

+ 210 - 0
src/FTTHBundle/Entity/PreSale.php

@@ -0,0 +1,210 @@
+<?php
+
+namespace FTTHBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
+use Gedmo\Mapping\Annotation as Gedmo;
+use JMS\Serializer\Annotation as JMS;
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
+use Symfony\Component\Validator\Constraints as Assert;
+
+/**
+ * @ORM\Entity
+ */
+class PreSale
+{
+
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="id", type="integer", nullable=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=100, nullable=true)
+     */
+    protected $address;
+
+    /**
+     * @var int
+     *
+     * @ORM\Column(type="integer", nullable=false)
+     *
+     * @Assert\NotNull
+     */
+    private $clientId;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="Profile", fetch="EXTRA_LAZY")
+     * @ORM\JoinColumn(name="profile_id", referencedColumnName="id", onDelete="SET NULL")
+     * 
+     * @Assert\NotNull
+     *
+     * @JMS\MaxDepth(1)
+     */
+    protected $profile;
+
+    /**
+     * @ORM\Column(type="datetime", nullable=true)
+     */
+    protected $date;
+
+    /**
+     * @ORM\Column(type="datetime")
+     * 
+     * @Gedmo\Timestampable(on="create")
+     */
+    protected $created;
+
+    /**
+     * @ORM\Column(type="datetime")
+     * 
+     * @Gedmo\Timestampable(on="update")
+     */
+    protected $updated;
+
+
+    /**
+     * @return string
+     */
+    public function __toString()
+    {
+        return (string)$this->clientId;
+    }
+
+    /**
+     * @return int
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * @param integer $clientId
+     *
+     * @return PreSale
+     */
+    public function setClientId($clientId)
+    {
+        $this->clientId = $clientId;
+
+        return $this;
+    }
+
+    /**
+     * @return int
+     */
+    public function getClientId()
+    {
+        return $this->clientId;
+    }
+
+    /**
+     * @param DateTime $date
+     * 
+     * @return PreSale
+     */
+    public function setDate($date)
+    {
+        $this->date = $date;
+
+        return $this;
+    }
+
+    /**
+     * @return DateTime
+     */
+    public function getDate()
+    {
+        return $this->date;
+    }
+
+    /**
+     * @return \DateTime
+     */
+    public function getCreated()
+    {
+        return $this->created;
+    }
+
+    /**
+     * @param \DateTime
+     *
+     * @return PreSale
+     */
+    public function setCreated($d)
+    {
+        $this->created = $d;
+        
+        return $this;
+    }
+
+
+    /**
+     * @return \DateTime
+     */
+    public function getUpdated()
+    {
+        return $this->updated;
+    }
+
+    /**
+     * @param \DateTime
+     *
+     * @return PreSale
+     */
+    public function setUpdated($updated)
+    {
+        $this->updated = $updated;
+
+        return $this;
+    }
+
+    /**
+     * @param Profile $profile
+     * 
+     * @return PreSale
+     */
+    public function setProfile($profile)
+    {
+        $this->profile = $profile;
+
+        return $this;
+    }
+
+    /**
+     * @return Profile
+     */
+    public function getProfile()
+    {
+        return $this->profile;
+    }
+    
+    /**
+     * @param string $address
+     *
+     * @return PreSale
+     */
+    public function setAddress($address)
+    {
+        $this->address = $address;
+
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getAddress()
+    {
+        return $this->address;
+    }
+
+}

+ 34 - 0
src/FTTHBundle/Form/PreSaleType.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace FTTHBundle\Form;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+
+class PreSaleType extends AbstractType
+{
+    /**
+     * @param FormBuilderInterface $builder
+     * @param array $options
+     */
+    public function buildForm(FormBuilderInterface $builder, array $options)
+    {
+        $builder
+            ->add('clientId')
+            ->add('profile')
+            ->add('address')
+            ->add('date')
+        ;
+    }
+
+    /**
+     * @param OptionsResolver $resolver
+     */
+    public function configureOptions(OptionsResolver $resolver)
+    {
+        $resolver->setDefaults(array(
+            'data_class' => 'FTTHBundle\Entity\PreSale'
+        ));
+    }
+}

+ 8 - 0
src/FTTHBundle/Resources/config/services.yml

@@ -112,6 +112,14 @@ services:
         calls:
             - [setTranslationDomain, [FTTHBundle]]
 
+    sonata.admin.PreSale:
+        class: FTTHBundle\Admin\PreSaleAdmin
+        arguments: [~, FTTHBundle\Entity\PreSale, BaseAdminBundle:CRUD]
+        tags:
+            - { name: sonata.admin, manager_type: orm, group: FTTH, label: presale, label_catalogue: FTTHBundle, label_translator_strategy: sonata.admin.label.strategy.underscore }
+        calls:
+            - [setTranslationDomain, [FTTHBundle]]
+
     sonata.admin.VLanID:
         class: FTTHBundle\Admin\VLanIDAdmin
         arguments: [~, FTTHBundle\Entity\VLanID, BaseAdminBundle:CRUD]

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

@@ -170,6 +170,8 @@ form:
     label_enable_pass: Enable Password
     label_ssh_port: SSH Port
     label_ssh_connect: Conexión por SSH
+    label_date: Fecha
+
 list:
     label_id: Id
     label_ip: Ip
@@ -238,6 +240,8 @@ list:
     label_ssh_connect: Conexión por SSH
     label_log_o_l_t_status: Conf. Status
     label_log_o_l_t_date: Fecha OLT
+    label_date: Fecha
+
 show:
     label_id: Id
     label_ip: Ip
@@ -314,6 +318,8 @@ show:
     label_log_o_l_t_status: Conf. Status
     label_log_o_l_t_date: Fecha OLT
     label_log_o_l_t_directory: Directorio log OLT
+    label_date: Fecha
+    
 helps:
     check_address: Verifique la dirección para el cálculo de distancias.
     onu_serial_number: Serial Number de la ONU conformado por 16 caracteres, si es vacío lo calculamos desde el Identificador.