src/Entity/FranjaDias.php line 380

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\Collection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use JsonSerializable;
  8. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  9. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  10. /**
  11.  * FranjaDias
  12.  *
  13.  * @ORM\Table(name="franja_dias")
  14.  * @ORM\Entity
  15.  */
  16. class FranjaDias implements \JsonSerializable,  TranslatableInterface
  17. {
  18.     use TranslatableTrait;
  19.     
  20.     /**
  21.      * @var integer
  22.      *
  23.      * @ORM\Column(name="id", type="integer")
  24.      * @ORM\Id
  25.      * @ORM\GeneratedValue(strategy="AUTO")
  26.      */
  27.     private $id;
  28.     /**
  29.      * @var boolean
  30.      *
  31.      * @ORM\Column(name="lunes", type="boolean")
  32.      */
  33.     private $lunes;
  34.     /**
  35.      * @var boolean
  36.      *
  37.      * @ORM\Column(name="martes", type="boolean")
  38.      */
  39.     private $martes;
  40.     /**
  41.      * @var boolean
  42.      *
  43.      * @ORM\Column(name="miercoles", type="boolean")
  44.      */
  45.     private $miercoles;
  46.     /**
  47.      * @var boolean
  48.      *
  49.      * @ORM\Column(name="jueves", type="boolean")
  50.      */
  51.     private $jueves;
  52.     /**
  53.      * @var boolean
  54.      *
  55.      * @ORM\Column(name="viernes", type="boolean")
  56.      */
  57.     private $viernes;
  58.     /**
  59.      * @var boolean
  60.      *
  61.      * @ORM\Column(name="sabado", type="boolean")
  62.      */
  63.     private $sabado;
  64.     /**
  65.      * @var boolean
  66.      *
  67.      * @ORM\Column(name="domingo", type="boolean")
  68.      */
  69.     private $domingo;
  70.     /**
  71.      * @Assert\Valid()
  72.      * @ORM\OneToMany(targetEntity="FranjaHoras", mappedBy="franjaDias", cascade={"persist", "remove"}, orphanRemoval=true)
  73.      */
  74.     private $franjaHoras;
  75.      
  76.     /**    
  77.     * @ORM\ManyToOne(targetEntity="Oficina", inversedBy="franjas"))
  78.     * @ORM\JoinColumn(name="oficina", referencedColumnName="id")
  79.     */
  80.     private $oficina;
  81.     
  82.     public function __call($method$args)
  83.     {
  84.         //return $this->proxyCurrentLocaleTranslation($method, $arguments);
  85.         if (!method_exists(self::getTranslationEntityClass(), $method)) {
  86.             $method 'get'ucfirst($method);
  87.         }
  88.         return $this->proxyCurrentLocaleTranslation($method$args);        
  89.     }
  90.     public function __construct() {
  91.         $this->franjaHoras = new ArrayCollection();
  92.     }
  93.     /**
  94.      * Get id
  95.      *
  96.      * @return integer 
  97.      */
  98.     public function getId()
  99.     {
  100.         return $this->id;
  101.     }
  102.     /**
  103.      * Set lunes
  104.      *
  105.      * @param boolean $lunes
  106.      * @return FranjaDias
  107.      */
  108.     public function setLunes($lunes)
  109.     {
  110.         $this->lunes $lunes;
  111.         return $this;
  112.     }
  113.     /**
  114.      * Get lunes
  115.      *
  116.      * @return boolean 
  117.      */
  118.     public function getLunes()
  119.     {
  120.         return $this->lunes;
  121.     }
  122.     /**
  123.      * Set martes
  124.      *
  125.      * @param boolean $martes
  126.      * @return FranjaDias
  127.      */
  128.     public function setMartes($martes)
  129.     {
  130.         $this->martes $martes;
  131.         return $this;
  132.     }
  133.     /**
  134.      * Get martes
  135.      *
  136.      * @return boolean 
  137.      */
  138.     public function getMartes()
  139.     {
  140.         return $this->martes;
  141.     }
  142.     /**
  143.      * Set miercoles
  144.      *
  145.      * @param boolean $miercoles
  146.      * @return FranjaDias
  147.      */
  148.     public function setMiercoles($miercoles)
  149.     {
  150.         $this->miercoles $miercoles;
  151.         return $this;
  152.     }
  153.     /**
  154.      * Get miercoles
  155.      *
  156.      * @return boolean 
  157.      */
  158.     public function getMiercoles()
  159.     {
  160.         return $this->miercoles;
  161.     }
  162.     /**
  163.      * Set jueves
  164.      *
  165.      * @param boolean $jueves
  166.      * @return FranjaDias
  167.      */
  168.     public function setJueves($jueves)
  169.     {
  170.         $this->jueves $jueves;
  171.         return $this;
  172.     }
  173.     /**
  174.      * Get jueves
  175.      *
  176.      * @return boolean 
  177.      */
  178.     public function getJueves()
  179.     {
  180.         return $this->jueves;
  181.     }
  182.     /**
  183.      * Set viernes
  184.      *
  185.      * @param boolean $viernes
  186.      * @return FranjaDias
  187.      */
  188.     public function setViernes($viernes)
  189.     {
  190.         $this->viernes $viernes;
  191.         return $this;
  192.     }
  193.     /**
  194.      * Get viernes
  195.      *
  196.      * @return boolean 
  197.      */
  198.     public function getViernes()
  199.     {
  200.         return $this->viernes;
  201.     }
  202.     /**
  203.      * Set sabado
  204.      *
  205.      * @param boolean $sabado
  206.      * @return FranjaDias
  207.      */
  208.     public function setSabado($sabado)
  209.     {
  210.         $this->sabado $sabado;
  211.         return $this;
  212.     }
  213.     /**
  214.      * Get sabado
  215.      *
  216.      * @return boolean 
  217.      */
  218.     public function getSabado()
  219.     {
  220.         return $this->sabado;
  221.     }
  222.     /**
  223.      * Set domingo
  224.      *
  225.      * @param boolean $domingo
  226.      * @return FranjaDias
  227.      */
  228.     public function setDomingo($domingo)
  229.     {
  230.         $this->domingo $domingo;
  231.         return $this;
  232.     }
  233.     /**
  234.      * Get domingo
  235.      *
  236.      * @return boolean 
  237.      */
  238.     public function getDomingo()
  239.     {
  240.         return $this->domingo;
  241.     }
  242.     /**
  243.      * Set oficina
  244.      *
  245.      * @param Oficina $oficina
  246.      * @return FranjaDias
  247.      */
  248.     public function setOficina(Oficina $oficina)
  249.     {
  250.         
  251.         $this->oficina $oficina;
  252.         return $this;
  253.     }
  254.     /**
  255.      * Get oficina
  256.      *
  257.      * @return boolean 
  258.      */
  259.     public function getOficina()
  260.     {
  261.         return $this->oficina;
  262.     }
  263.     /**
  264.      * Get dias
  265.      *
  266.      * @return array 
  267.      */
  268.     public function getFranjaDias()
  269.     {
  270.         $semana['lunes']=$this->lunes;
  271.         $semana['martes']=$this->martes;
  272.         $semana['miercoles']=$this->miercoles;
  273.         $semana['jueves']=$this->jueves;
  274.         $semana['viernes']=$this->viernes;
  275.         $semana['sabado']=$this->sabado;
  276.         $semana['domingo']=$this->domingo;
  277.         foreach ($this->franjaHoras as $franja){
  278.             $semana['franjas'][]=json_encode($franja->getFranjaHoras());
  279.         }
  280.         foreach ($this->translations as $traduccion) {
  281.             $semana['traducciones'][]=$traduccion->getNombre();
  282.         }
  283.         return $semana;
  284.     }
  285.     /**
  286.      * Set franjaHoras
  287.      *
  288.      * @param ArrayColection $franjaHoras
  289.      * @return FranjaDias
  290.      */
  291.     public function setFranjaHoras($franjaHoras)
  292.     {
  293.         $this->franjaHoras=$franjaHoras;
  294.         return $this;
  295.     }
  296.     /**
  297.      * Get nombre
  298.      *
  299.      * @return franjaHoras 
  300.      */
  301.     public function getFranjaHoras()
  302.     {
  303.         return $this->franjaHoras;
  304.     }
  305.     /**
  306.      * Set dias
  307.      *
  308.      * @param  array $semana
  309.      * @return FranjaDias 
  310.      */
  311.     public function setDias($semana)
  312.     {
  313.         $this->lunes=$semana['lunes'];
  314.         $this->martes=$semana['martes'];
  315.         $this->miercoles=$semana['miercoles'];
  316.         $this->jueves=$semana['jueves'];
  317.         $this->viernes=$semana['viernes'];
  318.         $this->sabado=$semana['sabado'];
  319.         $this->domingo=$semana['domingo'];
  320.         return $this;
  321.     }
  322.     public function __toString(){
  323.         return (string)  $this->id;
  324.     }
  325.     public function jsonSerialize()
  326.     {
  327.         return array(
  328.             'lunes' => $this->lunes,
  329.             'martes'=> $this->martes,
  330.             'miercoles'=> $this->miercoles,
  331.             'jueves'=> $this->jueves,
  332.             'viernes'=> $this->viernes,
  333.             'sabado'=> $this->sabado,
  334.             'domingo'=> $this->domingo,
  335.             'id'    => $this->id,
  336.             'franjaHoras' => json_encode($this->franjaHoras)
  337.         );
  338.     }
  339.     public function isLunes(): ?bool
  340.     {
  341.         return $this->lunes;
  342.     }
  343.     public function isMartes(): ?bool
  344.     {
  345.         return $this->martes;
  346.     }
  347.     public function isMiercoles(): ?bool
  348.     {
  349.         return $this->miercoles;
  350.     }
  351.     public function isJueves(): ?bool
  352.     {
  353.         return $this->jueves;
  354.     }
  355.     public function isViernes(): ?bool
  356.     {
  357.         return $this->viernes;
  358.     }
  359.     public function isSabado(): ?bool
  360.     {
  361.         return $this->sabado;
  362.     }
  363.     public function isDomingo(): ?bool
  364.     {
  365.         return $this->domingo;
  366.     }
  367.     public function addFranjaHora(FranjaHoras $franjaHora): self
  368.     {
  369.         if (!$this->franjaHoras->contains($franjaHora)) {
  370.             $this->franjaHoras->add($franjaHora);
  371.             $franjaHora->setFranjaDias($this);
  372.         }
  373.         return $this;
  374.     }
  375.     public function removeFranjaHora(FranjaHoras $franjaHora): self
  376.     {
  377.         if ($this->franjaHoras->removeElement($franjaHora)) {
  378.             // set the owning side to null (unless already changed)
  379.             if ($franjaHora->getFranjaDias() === $this) {
  380.                 $franjaHora->setFranjaDias(null);
  381.             }
  382.         }
  383.         return $this;
  384.     }  
  385. }