src/Diplix/KMGBundle/Entity/Availability.php line 334

Open in your IDE?
  1. <?php
  2. namespace Diplix\KMGBundle\Entity;
  3. use Diplix\KMGBundle\Entity\Accounting\CoopMember;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Table(name="availability", indexes={@ORM\Index(name="be_deleted",columns={"be_deleted"})})
  7.  * @ORM\Entity(repositoryClass="Diplix\KMGBundle\Repository\AvailabilityRepository")
  8.  */
  9. class Availability extends BasicEntity implements \JsonSerializable
  10. {
  11.     const RECUR_WEEKLY'W';
  12.     const RECUR_MONTHLY'M';
  13.     const RECUR_DAILY'D';
  14.     public static $recurMap = [
  15.         self::RECUR_DAILY   => 'Tag',
  16.         self::RECUR_WEEKLY  => 'Woche',
  17.         self::RECUR_MONTHLY => 'Monat'
  18.     ];
  19.     const KMG 'A';
  20.     const NOT_AVAILABLE 'N';
  21.     const UNKNOWN 'Z';
  22.     const READY 'R';
  23.     const FFL 'FFL';
  24.     const KLF 'KLF';
  25.     const BASF 'BASF';
  26.     const ZUSATZ 'ZUS';
  27.     const INFO 'I';
  28.     public static $displayMap = [
  29.         self::READY => "Bereit",
  30.         self::KMG => 'Belegt',
  31.         self::NOT_AVAILABLE => 'Nicht verfügbar',
  32.         self::UNKNOWN => 'Unbekannt',
  33.         self::FFL => ' FFL',
  34.         self::KLF => ' KLF',
  35.         self::BASF => 'BASF',
  36.         self::ZUSATZ => 'Zusatzfahrzeug',
  37.         self::INFO => 'Info'
  38.     ];
  39.     public static $shortDisplayMap = [
  40.         self::READY => '',
  41.         self::KMG => '',
  42.         self::NOT_AVAILABLE => 'N/V',
  43.         self::UNKNOWN => '?',
  44.         self::FFL => 'FFL',
  45.         self::KLF => 'KLF',
  46.         self::BASF => 'BASF',
  47.         self::ZUSATZ => 'Zusatz',
  48.         self::INFO => 'Info'
  49.     ];
  50.     public static $colorMap = [     // css color, pdf color
  51.         self::READY =>          [ 'royalblue',  [ 100,100,255]],
  52.         self::KMG =>      [ '#006400',    [ 200,240,200]],
  53.         self::FFL =>            [ '#00A800',    [ 200,255,200]],
  54.         self::KLF =>            [ '#00EE00',    [ 200,250,70]],
  55.         self::NOT_AVAILABLE =>  [ 'darkred',    [ 255,200,200]],
  56.         self::UNKNOWN =>        [ 'transparent',[ 200,200,200]],
  57.         self::BASF =>           [ '#FF00FF',    [ 255,200,255]],
  58.         self::ZUSATZ =>         [ '#F5F5F5',    [ 240,240,240]],
  59.         self::INFO =>           [ '#E6E600',    [ 230,230,0]  ]
  60.     ];
  61.     /**
  62.      * @ORM\Column(type="integer",name="id")
  63.      * @ORM\Id()
  64.      * @ORM\GeneratedValue(strategy="AUTO")
  65.      */
  66.     protected $id;
  67.     /**
  68.      * @ORM\Column(type="datetime",nullable=false)
  69.      */
  70.     protected $availFrom;
  71.     /**
  72.      * @ORM\Column(type="datetime",nullable=false)
  73.      */
  74.     protected $availUntil;
  75.     /**
  76.      * @ORM\Column(type="string", length=4, options={"fixed" = true})
  77.      */
  78.     protected $availType self::NOT_AVAILABLE;
  79.     /**
  80.      * @ORM\Column(type="string")
  81.      */
  82.     protected $extraInfo '';
  83.     /**
  84.      * @ORM\ManyToOne(targetEntity="Diplix\KMGBundle\Entity\Accounting\CoopMember")
  85.      * @ORM\JoinColumn(nullable=false)
  86.      */
  87.     protected $member;
  88.     /**
  89.      * @ORM\Column(type="boolean")
  90.      */
  91.     protected $recurring false;
  92.     /**
  93.      * @ORM\Column(type="string")
  94.      */
  95.     protected $recurType '';
  96.     /**
  97.      * @ORM\Column(type="integer")
  98.      */
  99.     protected $recurInterval 1;
  100.     /**
  101.      * @ORM\Column(type="datetime",nullable=true)
  102.      */
  103.     protected $recurEnd null;
  104.     /**
  105.      * @ORM\ManyToOne(targetEntity="Diplix\KMGBundle\Entity\Availability")
  106.      */
  107.     protected $recurParent null;
  108.     /**
  109.      * @ORM\Column(type="string", nullable=true)
  110.      */
  111.     protected $createdFromRemoteOrderId null;
  112.     public function contextAwareClone()
  113.     {
  114.         $a = clone $this;
  115.         $a->id null;
  116.         if ($this->getRecurring())
  117.         {
  118.             $a->setRecurParent($this);
  119.         }
  120.         $a->setRecurring(false);
  121.         $a->setBeCreated(new \DateTime());
  122.         $a->setBeEdited(null);
  123.         return $a;
  124.     }
  125.     /**
  126.      * @return mixed
  127.      */
  128.     public function getId()
  129.     {
  130.         return $this->id;
  131.     }
  132.     /**
  133.      * @return \DateTime|null
  134.      */
  135.     public function getAvailFrom()
  136.     {
  137.         return $this->availFrom;
  138.     }
  139.     /**
  140.      * @param mixed $availFrom
  141.      */
  142.     public function setAvailFrom($availFrom)
  143.     {
  144.         $this->availFrom $availFrom;
  145.     }
  146.     /**
  147.      * @return \DateTime|null
  148.      */
  149.     public function getAvailUntil()
  150.     {
  151.         return $this->availUntil;
  152.     }
  153.     /**
  154.      * @param mixed $availUntil
  155.      */
  156.     public function setAvailUntil($availUntil)
  157.     {
  158.         $this->availUntil $availUntil;
  159.     }
  160.     /**
  161.      * @return mixed
  162.      */
  163.     public function getAvailType()
  164.     {
  165.         return $this->availType;
  166.     }
  167.     /**
  168.      * @param mixed $availType
  169.      */
  170.     public function setAvailType($availType)
  171.     {
  172.         $this->availType $availType;
  173.     }
  174.     /**
  175.      * @return mixed
  176.      */
  177.     public function getExtraInfo()
  178.     {
  179.         return $this->extraInfo;
  180.     }
  181.     /**
  182.      * @param mixed $extraInfo
  183.      */
  184.     public function setExtraInfo($extraInfo)
  185.     {
  186.         $this->extraInfo $extraInfo;
  187.     }
  188.     /**
  189.      * @return CoopMember
  190.      */
  191.     public function getMember()
  192.     {
  193.         return $this->member;
  194.     }
  195.     /**
  196.      * @param mixed $member
  197.      */
  198.     public function setMember($member)
  199.     {
  200.         $this->member $member;
  201.     }
  202.     /**
  203.      * @return mixed
  204.      */
  205.     public function getRecurring()
  206.     {
  207.         return $this->recurring;
  208.     }
  209.     /**
  210.      * @param mixed $recurring
  211.      */
  212.     public function setRecurring($recurring)
  213.     {
  214.         $this->recurring $recurring;
  215.     }
  216.     /**
  217.      * @return mixed
  218.      */
  219.     public function getRecurType()
  220.     {
  221.         return $this->recurType;
  222.     }
  223.     /**
  224.      * @param mixed $recurType
  225.      */
  226.     public function setRecurType($recurType)
  227.     {
  228.         $this->recurType $recurType;
  229.     }
  230.     /**
  231.      * @return mixed
  232.      */
  233.     public function getRecurInterval()
  234.     {
  235.         return $this->recurInterval;
  236.     }
  237.     /**
  238.      * @param mixed $recurInterval
  239.      */
  240.     public function setRecurInterval($recurInterval)
  241.     {
  242.         $this->recurInterval $recurInterval;
  243.     }
  244.     /**
  245.      * @return mixed
  246.      */
  247.     public function getRecurParent()
  248.     {
  249.         return $this->recurParent;
  250.     }
  251.     /**
  252.      * @param mixed $recurParent
  253.      */
  254.     public function setRecurParent($recurParent)
  255.     {
  256.         $this->recurParent $recurParent;
  257.     }
  258.     /**
  259.      * @return null|\DateTime
  260.      */
  261.     public function getRecurEnd()
  262.     {
  263.         return $this->recurEnd;
  264.     }
  265.     /**
  266.      * @param mixed $recurEnd
  267.      */
  268.     public function setRecurEnd($recurEnd)
  269.     {
  270.         $this->recurEnd $recurEnd;
  271.     }
  272.     /**
  273.      * @return mixed
  274.      */
  275.     public function getCreatedFromRemoteOrderId()
  276.     {
  277.         return $this->createdFromRemoteOrderId;
  278.     }
  279.     /**
  280.      * @param mixed $createdFromRemoteOrderId
  281.      */
  282.     public function setCreatedFromRemoteOrderId($createdFromRemoteOrderId)
  283.     {
  284.         $this->createdFromRemoteOrderId $createdFromRemoteOrderId;
  285.     }
  286.     /**
  287.      * Specify data which should be serialized to JSON
  288.      */
  289.     function jsonSerialize()
  290.     {
  291.         return [
  292.             'id'=>$this->getId(),
  293.             'availFrom' => $this->getAvailFrom()->format("Y-m-d H:i"),
  294.             'availUntil' => $this->getAvailUntil()->format("Y-m-d H:i"),
  295.             'availType'=>$this->getAvailType(),
  296.             'extraInfo'=>$this->getExtraInfo(),
  297.             'member'=>$this->getMember()->getId(),
  298.             'beCreated'=> $this->getBeCreated() !== null ?  $this->getBeCreated()->format("Y-m-d H:i") : '',
  299.             'beEdited'=>$this->getBeEdited() !==null $this->getBeEdited()->format("Y-m-d H:i") : '',
  300.             'beOwner' => $this->getBeOwner()!==null ? [
  301.                 'id' => $this->getBeOwner()->getId(),
  302.                 'firstName'=>$this->getBeOwner()->getFirstName(),
  303.                 'lastName' => $this->getBeOwner()->getLastName()
  304.             ] : null,
  305.             'recurring' =>$this->getRecurring(),
  306.             'recurParent'=> ($this->getRecurParent() !== null $this->getRecurParent()->getId() : )
  307.         ];
  308.     }
  309. }