Advertisement
Guest User

Untitled

a guest
Aug 14th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.97 KB | None | 0 0
  1. <?php
  2.  
  3. namespace AppBundle\Entity;
  4.  
  5. use AppBundle\Model\TimestampableInterface;
  6. use AppBundle\Model\TimestampableTrait;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use JMS\Serializer\Annotation as JMS;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12.  
  13. /**
  14.  * @ORM\Table(
  15.  *      name="absences",
  16.  *      uniqueConstraints={@ORM\UniqueConstraint(
  17.  *          name="name_company",
  18.  *          columns={"company_id", "name"}
  19.  *      )}
  20.  * )
  21.  * @ORM\Entity(repositoryClass="AppBundle\Entity\Repository\AbsenceRepository")
  22.  * @ORM\HasLifecycleCallbacks
  23.  *
  24.  * @UniqueEntity(
  25.  *     fields={"company", "name"},
  26.  *     ignoreNull=false,
  27.  *     message="company.absence_name_already_exists_for_selected_company"
  28.  * )
  29.  *
  30.  * @JMS\ExclusionPolicy("all")
  31.  */
  32. class Absence implements TimestampableInterface
  33. {
  34.     use TimestampableTrait;
  35.  
  36.     const API_CARD = 'api__card';
  37.  
  38.     const SICK_LEAVE            = 'sick_leave';
  39.     const VACATION              = 'vacation';
  40.     const ARMY                  = 'army';
  41.     const MATERNITY_LEAVE       = 'maternity_leave';
  42.     const UNPAID_VACATION       = 'unpaid_vacation';
  43.     const MOURNING              = 'mourning';
  44.     const TEAM_BUILDER_ACTIVITY = 'team_builder_activity';
  45.     const HOLIDAY               = 'holiday';
  46.  
  47.     /**
  48.      * @var array
  49.      */
  50.     public static $defaultAbsences = [
  51.         self::VACATION,
  52.         self::SICK_LEAVE,
  53.         self::UNPAID_VACATION,
  54.         self::MATERNITY_LEAVE,
  55.         self::HOLIDAY,
  56.         self::ARMY,
  57.         self::TEAM_BUILDER_ACTIVITY,
  58.         self::MOURNING,
  59.     ];
  60.  
  61.     /**
  62.      * @var array
  63.      */
  64.     public static $absenceNumbers = [
  65.         self::SICK_LEAVE            => 1,
  66.         self::VACATION              => 2,
  67.         self::ARMY                  => 3,
  68.         self::MATERNITY_LEAVE       => 4,
  69.         self::UNPAID_VACATION       => 5,
  70.         self::MOURNING              => 6,
  71.         self::TEAM_BUILDER_ACTIVITY => 7,
  72.         self::HOLIDAY               => 8,
  73.     ];
  74.  
  75.     public static $hebrewMap = [
  76.         'sick_leave' => 'מחלה',
  77.         'vacation' => 'חופשה',
  78.         'army' => 'צבא',
  79.         'maternity_leave' => 'חופשת לידה',
  80.         'unpaid_vacation' => 'חל"ת',
  81.         'mourning' => 'אבל',
  82.         'team_builder_activity' => 'פעילות גיבוש בחברה',
  83.         'holiday' => 'חג',
  84.     ];
  85.  
  86.     public static $englishMap = [
  87.         'sick_leave' => 'Sick leave',
  88.         'vacation' => 'Vacation',
  89.         'army' => 'Army',
  90.         'maternity_leave' => 'Maternity leave',
  91.         'unpaid_vacation' => 'Unpaid vacation',
  92.         'mourning' => 'Mourning',
  93.         'team_builder_activity' => 'Team builder activity',
  94.         'holiday' => 'Holiday',
  95.     ];
  96.  
  97.     /**
  98.      * @var int
  99.      *
  100.      * @ORM\Column(name="id", type="integer")
  101.      * @ORM\Id
  102.      * @ORM\GeneratedValue(strategy="AUTO")
  103.      */
  104.     private $id;
  105.  
  106.     /**
  107.      * @var string
  108.      *
  109.      * @Assert\NotBlank()
  110.      *
  111.      * @JMS\Expose()
  112.      * @JMS\Groups({Absence::API_CARD})
  113.      *
  114.      * @ORM\Column(name="name", type="string")
  115.      */
  116.     private $name;
  117.  
  118.     /**
  119.      * @var bool
  120.      *
  121.      * @ORM\Column(name="paid", type="boolean", options={"default" = false})
  122.      */
  123.     private $paid = false;
  124.  
  125.     /**
  126.      * @var int|null
  127.      *
  128.      * @ORM\Column(name="michpal_number", type="integer", nullable=true)
  129.      */
  130.     private $michpalNumber;
  131.  
  132.     /**
  133.      * @var Companies
  134.      *
  135.      * @Assert\NotNull()
  136.      *
  137.      * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Companies", cascade={"persist"}, inversedBy="absences")
  138.      * @ORM\JoinColumn(name="company_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  139.      */
  140.     private $company;
  141.  
  142.     /**
  143.      * @var ActivityLog[]|ArrayCollection
  144.      *
  145.      * @ORM\OneToMany(targetEntity="AppBundle\Entity\ActivityLog", mappedBy="absence")
  146.      */
  147.     private $sessions;
  148.  
  149.     public function __construct()
  150.     {
  151.         $this->sessions = new ArrayCollection();
  152.     }
  153.  
  154.     /**
  155.      * @return int
  156.      */
  157.     public function getId()
  158.     {
  159.         return $this->id;
  160.     }
  161.  
  162.     /**
  163.      * @param string $name
  164.      *
  165.      * @return Absence
  166.      */
  167.     public function setName($name)
  168.     {
  169.         $this->name = $name;
  170.  
  171.         return $this;
  172.     }
  173.  
  174.     /**
  175.      * @return string
  176.      */
  177.     public function getName()
  178.     {
  179.         return $this->name;
  180.     }
  181.  
  182.     /**
  183.      * @param bool $paid
  184.      *
  185.      * @return Absence
  186.      */
  187.     public function setPaid($paid)
  188.     {
  189.         $this->paid = $paid;
  190.  
  191.         return $this;
  192.     }
  193.  
  194.     /**
  195.      * @return bool
  196.      */
  197.     public function isPaid()
  198.     {
  199.         return $this->paid;
  200.     }
  201.  
  202.     /**
  203.      * @param int|null $michpalNumber
  204.      *
  205.      * @return Absence
  206.      */
  207.     public function setMichpalNumber($michpalNumber)
  208.     {
  209.         $this->michpalNumber = $michpalNumber;
  210.  
  211.         return $this;
  212.     }
  213.  
  214.     /**
  215.      * @return int|null
  216.      */
  217.     public function getMichpalNumber()
  218.     {
  219.         return $this->michpalNumber;
  220.     }
  221.  
  222.     /**
  223.      * @param Companies $company
  224.      *
  225.      * @return Absence
  226.      */
  227.     public function setCompany($company)
  228.     {
  229.         $this->company = $company;
  230.  
  231.         return $this;
  232.     }
  233.  
  234.     /**
  235.      * @return Companies
  236.      */
  237.     public function getCompany()
  238.     {
  239.         return $this->company;
  240.     }
  241.  
  242.     /**
  243.      * @param ActivityLog[]|ArrayCollection $sessions
  244.      *
  245.      * @return Absence
  246.      */
  247.     public function setSessions($sessions)
  248.     {
  249.         $this->sessions = $sessions;
  250.  
  251.         return $this;
  252.     }
  253.  
  254.     /**
  255.      * @return ActivityLog[]|ArrayCollection
  256.      */
  257.     public function getSessions()
  258.     {
  259.         return $this->sessions;
  260.     }
  261.  
  262.     /**
  263.      * @return string
  264.      */
  265.     public function __toString()
  266.     {
  267.         return $this->getName();
  268.     }
  269. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement