SHARE
TWEET

Untitled

a guest Mar 26th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  139.     public function getId() {
  140.         return $this->id;
  141.     }
  142.  
  143.     public function getJobNo(): ?string {
  144.         return $this->jobNo;
  145.     }
  146.  
  147.     public function setJobNo(string $jobNo): self {
  148.         $this->jobNo = $jobNo;
  149.  
  150.         return $this;
  151.     }
  152.  
  153.     public function getCustomer(): ?Customer {
  154.         return $this->customer;
  155.     }
  156.  
  157.     public function setCustomer(?Customer $customer): self {
  158.         $this->customer = $customer;
  159.  
  160.         return $this;
  161.     }
  162.  
  163.     public function getQuay(): ?Quay {
  164.         return $this->quay;
  165.     }
  166.  
  167.     public function setQuay(?Quay $quay): self {
  168.         $this->quay = $quay;
  169.  
  170.         return $this;
  171.     }
  172.  
  173.     public function getVesselName(): ?Ship {
  174.         return $this->vesselName;
  175.     }
  176.  
  177.     public function setVesselName(?Ship $vesselName): self {
  178.         $this->vesselName = $vesselName;
  179.  
  180.         return $this;
  181.     }
  182.  
  183.     public function getShoreTankNo(): ?string {
  184.         return $this->shoreTankNo;
  185.     }
  186.  
  187.     public function setShoreTankNo(?string $shoreTankNo): self {
  188.         $this->shoreTankNo = $shoreTankNo;
  189.  
  190.         return $this;
  191.     }
  192.  
  193.     public function getQuantity() {
  194.         return $this->quantity;
  195.     }
  196.  
  197.     public function setQuantity($quantity): self {
  198.         $this->quantity = $quantity;
  199.  
  200.         return $this;
  201.     }
  202.  
  203.     public function getDeliveryMethod(): ?int {
  204.         return $this->deliveryMethod;
  205.     }
  206.  
  207.     public function setDeliveryMethod(int $deliveryMethod): self {
  208.         $this->deliveryMethod = $deliveryMethod;
  209.  
  210.         return $this;
  211.     }
  212.  
  213.     public function getConnectionType(): ?int {
  214.         return $this->connectionType;
  215.     }
  216.  
  217.     public function setConnectionType(int $connectionType): self {
  218.         $this->connectionType = $connectionType;
  219.  
  220.         return $this;
  221.     }
  222.  
  223.     public function getEstimatedStartTime(): ?\DateTimeInterface {
  224.         return $this->estimatedStartTime;
  225.     }
  226.  
  227.     public function setEstimatedStartTime($estimatedStartTime): self {
  228.         $this->estimatedStartTime = new \DateTime($estimatedStartTime);
  229.  
  230.         return $this;
  231.     }
  232.  
  233.     public function getEstimatedEndTime(): ?\DateTimeInterface {
  234.         return $this->estimatedEndTime;
  235.     }
  236.  
  237.     public function setEstimatedEndTime( $estimatedEndTime): self {
  238.         $this->estimatedEndTime = new \DateTime($estimatedEndTime);
  239.  
  240.         return $this;
  241.     }
  242.  
  243.     public function getEta(): ?\DateTimeInterface {
  244.         return $this->eta;
  245.     }
  246.  
  247.     public function setEta( $eta): self {
  248.         $this->eta = new \DateTime($eta);
  249.  
  250.         return $this;
  251.     }
  252.  
  253.     public function getStartTime(): ?\DateTimeInterface {
  254.         return $this->startTime;
  255.     }
  256.  
  257.     public function setStartTime( $startTime): self {
  258.         $this->startTime = new \DateTime($startTime);
  259.  
  260.         return $this;
  261.     }
  262.  
  263.     public function getEndTime(): ?\DateTimeInterface {
  264.         return $this->endTime;
  265.     }
  266.  
  267.     public function setEndTime(?\DateTimeInterface $endTime): self {
  268.         $this->endTime = $endTime;
  269.  
  270.         return $this;
  271.     }
  272.  
  273.     public function getTrolleyNo(): ?string {
  274.         return $this->trolleyNo;
  275.     }
  276.  
  277.     public function setTrolleyNo(?string $trolleyNo): self {
  278.         $this->trolleyNo = $trolleyNo;
  279.  
  280.         return $this;
  281.     }
  282.  
  283.     public function getAverageFlowRate() {
  284.         return $this->averageFlowRate;
  285.     }
  286.  
  287.     public function setAverageFlowRate($averageFlowRate): self {
  288.         $this->averageFlowRate = $averageFlowRate;
  289.  
  290.         return $this;
  291.     }
  292.  
  293.     public function getMeterStart() {
  294.         return $this->meterStart;
  295.     }
  296.  
  297.     public function setMeterStart($meterStart): self {
  298.         $this->meterStart = $meterStart;
  299.  
  300.         return $this;
  301.     }
  302.  
  303.     public function getMeterEnd() {
  304.         return $this->meterEnd;
  305.     }
  306.  
  307.     public function setMeterEnd($meterEnd): self {
  308.         $this->meterEnd = $meterEnd;
  309.  
  310.         return $this;
  311.     }
  312.  
  313.     public function getCreatedAt(): ?\DateTimeInterface {
  314.         return $this->createdAt;
  315.     }
  316.  
  317.     public function setCreatedAt(\DateTimeInterface $createdAt): self {
  318.         $this->createdAt = $createdAt;
  319.  
  320.         return $this;
  321.     }
  322.  
  323.     public function getUpdatedAt(): ?\DateTimeInterface {
  324.         return $this->updatedAt;
  325.     }
  326.  
  327.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self {
  328.         $this->updatedAt = $updatedAt;
  329.  
  330.         return $this;
  331.     }
  332.  
  333.     public function getCreatedBy(): ?User {
  334.         return $this->createdBy;
  335.     }
  336.  
  337.     public function setCreatedBy(?User $createdBy): self {
  338.         $this->createdBy = $createdBy;
  339.  
  340.         return $this;
  341.     }
  342.    
  343.     public function getUpdatedBy(): ?User
  344.     {
  345.         return $this->updatedBy;
  346.     }
  347.  
  348.     public function setUpdatedBy(?User $updatedBy): self
  349.     {
  350.         $this->updatedBy = $updatedBy;
  351.  
  352.         return $this;
  353.     }
  354.    
  355.     /**
  356.      * @ORM\PrePersist
  357.      */
  358.     public function setDefaultValue() {
  359.         global $kernel;
  360.  
  361.         $container = $kernel->getContainer();
  362.         $currentUser = $container->get('security.token_storage')->getToken()->getUser();
  363.         $em = $container->get("doctrine")->getManager();
  364.  
  365.         // Setting the current values before insert
  366.         $this->jobNo = 'JIO19'.rand(100, 200);
  367.         $this->setCreatedBy($currentUser);
  368.         $this->setCreatedAt(new DateTime("now"));
  369.         $this->setUpdatedBy($currentUser);
  370.         $this->setUpdatedAt(new DateTime("now"));
  371.     }
  372.  
  373.     /**
  374.      * @ORM\PreUpdate
  375.      */
  376.     public function setUpdatedValues() {
  377.         global $kernel;
  378.  
  379.         $container = $kernel->getContainer();
  380.         $currentUser = $container->get('security.token_storage')->getToken()->getUser();
  381.         $em = $container->get("doctrine")->getManager();
  382.  
  383.  
  384.  
  385.         // Updated At
  386.         $this->setUpdatedAt(new DateTime("now"));
  387.         $this->setUpdatedBy($currentUser);
  388.     }
  389.  
  390.    
  391.  
  392. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top