Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.04 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6. use DateTime;
  7. use JMS\Serializer\Annotation\MaxDepth;
  8. use \App\Helper\ControllerHelper;
  9.  
  10. /**
  11.  * @ORM\HasLifecycleCallbacks
  12.  * @ORM\Entity(repositoryClass="App\Repository\BunkerRepository")
  13.  */
  14. class Bunker {
  15.  
  16.     /**
  17.      * @ORM\Id()
  18.      * @ORM\GeneratedValue()
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.  
  23.     /**
  24.      * @ORM\Column(type="string", length=10)
  25.      */
  26.     private $jobNo;
  27.  
  28.     /**
  29.      * @ORM\ManyToOne(targetEntity="App\Entity\Customer", inversedBy="bunkers")
  30.      * @ORM\JoinColumn(name="customer", nullable=true)
  31.      * @MaxDepth(1)
  32.      */
  33.     private $customer;
  34.  
  35.     /**
  36.      * @ORM\ManyToOne(targetEntity="App\Entity\Quay", inversedBy="bunkers")
  37.      * @ORM\JoinColumn(name="quay", nullable=true)
  38.      * @MaxDepth(1)
  39.      */
  40.     private $quay;
  41.  
  42.     /**
  43.      * @ORM\ManyToOne(targetEntity="App\Entity\Ship", inversedBy="bunkers")
  44.      * @ORM\JoinColumn(name="vessel_name", nullable=true)
  45.      * @MaxDepth(1)
  46.      */
  47.     private $vesselName;
  48.  
  49.     /**
  50.      * @ORM\Column(type="string", length=20, nullable=true)
  51.      */
  52.     private $shoreTankNo;
  53.  
  54.     /**
  55.      * @ORM\Column(type="decimal", precision=10, scale=2)
  56.      */
  57.     private $quantity;
  58.  
  59.     /**
  60.      * @ORM\Column(type="integer")
  61.      */
  62.     private $deliveryMethod;
  63.  
  64.     /**
  65.      * @ORM\Column(type="integer")
  66.      */
  67.     private $connectionType;
  68.  
  69.     /**
  70.      * @ORM\Column(type="time")
  71.      */
  72.     private $estimatedStartTime;
  73.  
  74.     /**
  75.      * @ORM\Column(type="time")
  76.      */
  77.     private $estimatedEndTime;
  78.  
  79.     /**
  80.      * @ORM\Column(type="time")
  81.      */
  82.     private $eta;
  83.  
  84.     /**
  85.      * @ORM\Column(type="time")
  86.      */
  87.     private $startTime;
  88.  
  89.     /**
  90.      * @ORM\Column(type="time", nullable=true)
  91.      */
  92.     private $endTime;
  93.  
  94.     /**
  95.      * @ORM\Column(type="string", length=10, nullable=true)
  96.      */
  97.     private $trolleyNo;
  98.  
  99.     /**
  100.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  101.      */
  102.     private $averageFlowRate;
  103.  
  104.     /**
  105.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  106.      */
  107.     private $meterStart;
  108.  
  109.     /**
  110.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  111.      */
  112.     private $meterEnd;
  113.  
  114.     /**
  115.      * @ORM\Column(type="datetime")
  116.      */
  117.     private $createdAt;
  118.  
  119.     /**
  120.      * @ORM\Column(type="datetime")
  121.      */
  122.     private $updatedAt;
  123.  
  124.     /**
  125.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="bunkers")
  126.      * @ORM\JoinColumn(name="created_by", nullable=true)
  127.      * @MaxDepth(1)    
  128.      */
  129.     private $createdBy;
  130.  
  131.     /**
  132.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  133.      * @ORM\JoinColumn(name="updated_by", nullable=false)
  134.      */
  135.     private $updatedBy;
  136.  
  137.     /**
  138.      * @ORM\ManyToOne(targetEntity="App\Entity\ShipType")
  139.      */
  140.     private $shipType;
  141.  
  142.  
  143.     public function getId() {
  144.         return $this->id;
  145.     }
  146.  
  147.     public function getJobNo(): ?string {
  148.         return $this->jobNo;
  149.     }
  150.  
  151.     public function setJobNo(string $jobNo): self {
  152.         $this->jobNo = $jobNo;
  153.  
  154.         return $this;
  155.     }
  156.  
  157.     public function getCustomer(): ?Customer {
  158.         return $this->customer;
  159.     }
  160.  
  161.     public function setCustomer(?Customer $customer): self {
  162.         $this->customer = $customer;
  163.  
  164.         return $this;
  165.     }
  166.  
  167.     public function getQuay(): ?Quay {
  168.         return $this->quay;
  169.     }
  170.  
  171.     public function setQuay(?Quay $quay): self {
  172.         $this->quay = $quay;
  173.  
  174.         return $this;
  175.     }
  176.  
  177.     public function getVesselName(): ?Ship {
  178.         return $this->vesselName;
  179.     }
  180.  
  181.     public function setVesselName(?Ship $vesselName): self {
  182.         $this->vesselName = $vesselName;
  183.  
  184.         return $this;
  185.     }
  186.  
  187.     public function getShoreTankNo(): ?string {
  188.         return $this->shoreTankNo;
  189.     }
  190.  
  191.     public function setShoreTankNo(?string $shoreTankNo): self {
  192.         $this->shoreTankNo = $shoreTankNo;
  193.  
  194.         return $this;
  195.     }
  196.  
  197.     public function getQuantity() {
  198.         return $this->quantity;
  199.     }
  200.  
  201.     public function setQuantity($quantity): self {
  202.         $this->quantity = $quantity;
  203.  
  204.         return $this;
  205.     }
  206.  
  207.     public function getDeliveryMethod(): ?int {
  208.         return $this->deliveryMethod;
  209.     }
  210.  
  211.     public function setDeliveryMethod(int $deliveryMethod): self {
  212.         $this->deliveryMethod = $deliveryMethod;
  213.  
  214.         return $this;
  215.     }
  216.  
  217.     public function getConnectionType(): ?int {
  218.         return $this->connectionType;
  219.     }
  220.  
  221.     public function setConnectionType(int $connectionType): self {
  222.         $this->connectionType = $connectionType;
  223.  
  224.         return $this;
  225.     }
  226.  
  227.     public function getEstimatedStartTime(): ?\DateTimeInterface {
  228.         return $this->estimatedStartTime;
  229.     }
  230.  
  231.     public function setEstimatedStartTime($estimatedStartTime): self {
  232.         $this->estimatedStartTime = new \DateTime($estimatedStartTime);
  233.  
  234.         return $this;
  235.     }
  236.  
  237.     public function getEstimatedEndTime(): ?\DateTimeInterface {
  238.         return $this->estimatedEndTime;
  239.     }
  240.  
  241.     public function setEstimatedEndTime( $estimatedEndTime): self {
  242.         $this->estimatedEndTime = new \DateTime($estimatedEndTime);
  243.  
  244.         return $this;
  245.     }
  246.  
  247.     public function getEta(): ?\DateTimeInterface {
  248.         return $this->eta;
  249.     }
  250.  
  251.     public function setEta( $eta): self {
  252.         $this->eta = new \DateTime($eta);
  253.  
  254.         return $this;
  255.     }
  256.  
  257.     public function getStartTime(): ?\DateTimeInterface {
  258.         return $this->startTime;
  259.     }
  260.  
  261.     public function setStartTime( $startTime): self {
  262.         $this->startTime = new \DateTime($startTime);
  263.  
  264.         return $this;
  265.     }
  266.  
  267.     public function getEndTime(): ?\DateTimeInterface {
  268.         return $this->endTime;
  269.     }
  270.  
  271.     public function setEndTime(?\DateTimeInterface $endTime): self {
  272.         $this->endTime = $endTime;
  273.  
  274.         return $this;
  275.     }
  276.  
  277.     public function getTrolleyNo(): ?string {
  278.         return $this->trolleyNo;
  279.     }
  280.  
  281.     public function setTrolleyNo(?string $trolleyNo): self {
  282.         $this->trolleyNo = $trolleyNo;
  283.  
  284.         return $this;
  285.     }
  286.  
  287.     public function getAverageFlowRate() {
  288.         return $this->averageFlowRate;
  289.     }
  290.  
  291.     public function setAverageFlowRate($averageFlowRate): self {
  292.         $this->averageFlowRate = $averageFlowRate;
  293.  
  294.         return $this;
  295.     }
  296.  
  297.     public function getMeterStart() {
  298.         return $this->meterStart;
  299.     }
  300.  
  301.     public function setMeterStart($meterStart): self {
  302.         $this->meterStart = $meterStart;
  303.  
  304.         return $this;
  305.     }
  306.  
  307.     public function getMeterEnd() {
  308.         return $this->meterEnd;
  309.     }
  310.  
  311.     public function setMeterEnd($meterEnd): self {
  312.         $this->meterEnd = $meterEnd;
  313.  
  314.         return $this;
  315.     }
  316.  
  317.     public function getCreatedAt(): ?\DateTimeInterface {
  318.         return $this->createdAt;
  319.     }
  320.  
  321.     public function setCreatedAt(\DateTimeInterface $createdAt): self {
  322.         $this->createdAt = $createdAt;
  323.  
  324.         return $this;
  325.     }
  326.  
  327.     public function getUpdatedAt(): ?\DateTimeInterface {
  328.         return $this->updatedAt;
  329.     }
  330.  
  331.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self {
  332.         $this->updatedAt = $updatedAt;
  333.  
  334.         return $this;
  335.     }
  336.  
  337.     public function getCreatedBy(): ?User {
  338.         return $this->createdBy;
  339.     }
  340.  
  341.     public function setCreatedBy(?User $createdBy): self {
  342.         $this->createdBy = $createdBy;
  343.  
  344.         return $this;
  345.     }
  346.    
  347.     public function getUpdatedBy(): ?User
  348.     {
  349.         return $this->updatedBy;
  350.     }
  351.  
  352.     public function setUpdatedBy(?User $updatedBy): self
  353.     {
  354.         $this->updatedBy = $updatedBy;
  355.  
  356.         return $this;
  357.     }
  358.    
  359.     /**
  360.      * @ORM\PrePersist
  361.      */
  362.     public function setDefaultValue() {
  363.         global $kernel;
  364.  
  365.         $container = $kernel->getContainer();
  366.         $currentUser = $container->get('security.token_storage')->getToken()->getUser();
  367.         $em = $container->get("doctrine")->getManager();
  368.  
  369.         // Setting the current values before insert
  370.         $this->jobNo = 'JIO19'.rand(100, 200);
  371.         $this->setCreatedBy($currentUser);
  372.         $this->setCreatedAt(new DateTime("now"));
  373.         $this->setUpdatedBy($currentUser);
  374.         $this->setUpdatedAt(new DateTime("now"));
  375.     }
  376.  
  377.     /**
  378.      * @ORM\PreUpdate
  379.      */
  380.     public function setUpdatedValues() {
  381.         global $kernel;
  382.  
  383.         $container = $kernel->getContainer();
  384.         $currentUser = $container->get('security.token_storage')->getToken()->getUser();
  385.         $em = $container->get("doctrine")->getManager();
  386.  
  387.  
  388.  
  389.         // Updated At
  390.         $this->setUpdatedAt(new DateTime("now"));
  391.         $this->setUpdatedBy($currentUser);
  392.     }
  393.  
  394.     public function getShipType(): ?ShipType
  395.     {
  396.         return $this->shipType;
  397.     }
  398.  
  399.     public function setShipType(?ShipType $shipType): self
  400.     {
  401.         $this->shipType = $shipType;
  402.  
  403.         return $this;
  404.     }
  405.  
  406. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement