Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use DateTime;
- use JMS\Serializer\Annotation\MaxDepth;
- use \App\Helper\ControllerHelper;
- /**
- * @ORM\HasLifecycleCallbacks
- * @ORM\Entity(repositoryClass="App\Repository\BunkerRepository")
- */
- class Bunker {
- /**
- * @ORM\Id()
- * @ORM\GeneratedValue()
- * @ORM\Column(type="integer")
- */
- private $id;
- /**
- * @ORM\Column(type="string", length=10)
- */
- private $jobNo;
- /**
- * @ORM\ManyToOne(targetEntity="App\Entity\Customer", inversedBy="bunkers")
- * @ORM\JoinColumn(name="customer", nullable=true)
- * @MaxDepth(1)
- */
- private $customer;
- /**
- * @ORM\ManyToOne(targetEntity="App\Entity\Quay", inversedBy="bunkers")
- * @ORM\JoinColumn(name="quay", nullable=true)
- * @MaxDepth(1)
- */
- private $quay;
- /**
- * @ORM\ManyToOne(targetEntity="App\Entity\Ship", inversedBy="bunkers")
- * @ORM\JoinColumn(name="vessel_name", nullable=true)
- * @MaxDepth(1)
- */
- private $vesselName;
- /**
- * @ORM\Column(type="string", length=20, nullable=true)
- */
- private $shoreTankNo;
- /**
- * @ORM\Column(type="decimal", precision=10, scale=2)
- */
- private $quantity;
- /**
- * @ORM\Column(type="integer")
- */
- private $deliveryMethod;
- /**
- * @ORM\Column(type="integer")
- */
- private $connectionType;
- /**
- * @ORM\Column(type="time")
- */
- private $estimatedStartTime;
- /**
- * @ORM\Column(type="time")
- */
- private $estimatedEndTime;
- /**
- * @ORM\Column(type="time")
- */
- private $eta;
- /**
- * @ORM\Column(type="time")
- */
- private $startTime;
- /**
- * @ORM\Column(type="time", nullable=true)
- */
- private $endTime;
- /**
- * @ORM\Column(type="string", length=10, nullable=true)
- */
- private $trolleyNo;
- /**
- * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
- */
- private $averageFlowRate;
- /**
- * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
- */
- private $meterStart;
- /**
- * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
- */
- private $meterEnd;
- /**
- * @ORM\Column(type="datetime")
- */
- private $createdAt;
- /**
- * @ORM\Column(type="datetime")
- */
- private $updatedAt;
- /**
- * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="bunkers")
- * @ORM\JoinColumn(name="created_by", nullable=true)
- * @MaxDepth(1)
- */
- private $createdBy;
- /**
- * @ORM\ManyToOne(targetEntity="App\Entity\User")
- * @ORM\JoinColumn(name="updated_by", nullable=false)
- */
- private $updatedBy;
- public function getId() {
- return $this->id;
- }
- public function getJobNo(): ?string {
- return $this->jobNo;
- }
- public function setJobNo(string $jobNo): self {
- $this->jobNo = $jobNo;
- return $this;
- }
- public function getCustomer(): ?Customer {
- return $this->customer;
- }
- public function setCustomer(?Customer $customer): self {
- $this->customer = $customer;
- return $this;
- }
- public function getQuay(): ?Quay {
- return $this->quay;
- }
- public function setQuay(?Quay $quay): self {
- $this->quay = $quay;
- return $this;
- }
- public function getVesselName(): ?Ship {
- return $this->vesselName;
- }
- public function setVesselName(?Ship $vesselName): self {
- $this->vesselName = $vesselName;
- return $this;
- }
- public function getShoreTankNo(): ?string {
- return $this->shoreTankNo;
- }
- public function setShoreTankNo(?string $shoreTankNo): self {
- $this->shoreTankNo = $shoreTankNo;
- return $this;
- }
- public function getQuantity() {
- return $this->quantity;
- }
- public function setQuantity($quantity): self {
- $this->quantity = $quantity;
- return $this;
- }
- public function getDeliveryMethod(): ?int {
- return $this->deliveryMethod;
- }
- public function setDeliveryMethod(int $deliveryMethod): self {
- $this->deliveryMethod = $deliveryMethod;
- return $this;
- }
- public function getConnectionType(): ?int {
- return $this->connectionType;
- }
- public function setConnectionType(int $connectionType): self {
- $this->connectionType = $connectionType;
- return $this;
- }
- public function getEstimatedStartTime(): ?\DateTimeInterface {
- return $this->estimatedStartTime;
- }
- public function setEstimatedStartTime($estimatedStartTime): self {
- $this->estimatedStartTime = new \DateTime($estimatedStartTime);
- return $this;
- }
- public function getEstimatedEndTime(): ?\DateTimeInterface {
- return $this->estimatedEndTime;
- }
- public function setEstimatedEndTime( $estimatedEndTime): self {
- $this->estimatedEndTime = new \DateTime($estimatedEndTime);
- return $this;
- }
- public function getEta(): ?\DateTimeInterface {
- return $this->eta;
- }
- public function setEta( $eta): self {
- $this->eta = new \DateTime($eta);
- return $this;
- }
- public function getStartTime(): ?\DateTimeInterface {
- return $this->startTime;
- }
- public function setStartTime( $startTime): self {
- $this->startTime = new \DateTime($startTime);
- return $this;
- }
- public function getEndTime(): ?\DateTimeInterface {
- return $this->endTime;
- }
- public function setEndTime(?\DateTimeInterface $endTime): self {
- $this->endTime = $endTime;
- return $this;
- }
- public function getTrolleyNo(): ?string {
- return $this->trolleyNo;
- }
- public function setTrolleyNo(?string $trolleyNo): self {
- $this->trolleyNo = $trolleyNo;
- return $this;
- }
- public function getAverageFlowRate() {
- return $this->averageFlowRate;
- }
- public function setAverageFlowRate($averageFlowRate): self {
- $this->averageFlowRate = $averageFlowRate;
- return $this;
- }
- public function getMeterStart() {
- return $this->meterStart;
- }
- public function setMeterStart($meterStart): self {
- $this->meterStart = $meterStart;
- return $this;
- }
- public function getMeterEnd() {
- return $this->meterEnd;
- }
- public function setMeterEnd($meterEnd): self {
- $this->meterEnd = $meterEnd;
- return $this;
- }
- public function getCreatedAt(): ?\DateTimeInterface {
- return $this->createdAt;
- }
- public function setCreatedAt(\DateTimeInterface $createdAt): self {
- $this->createdAt = $createdAt;
- return $this;
- }
- public function getUpdatedAt(): ?\DateTimeInterface {
- return $this->updatedAt;
- }
- public function setUpdatedAt(\DateTimeInterface $updatedAt): self {
- $this->updatedAt = $updatedAt;
- return $this;
- }
- public function getCreatedBy(): ?User {
- return $this->createdBy;
- }
- public function setCreatedBy(?User $createdBy): self {
- $this->createdBy = $createdBy;
- return $this;
- }
- public function getUpdatedBy(): ?User
- {
- return $this->updatedBy;
- }
- public function setUpdatedBy(?User $updatedBy): self
- {
- $this->updatedBy = $updatedBy;
- return $this;
- }
- /**
- * @ORM\PrePersist
- */
- public function setDefaultValue() {
- global $kernel;
- $container = $kernel->getContainer();
- $currentUser = $container->get('security.token_storage')->getToken()->getUser();
- $em = $container->get("doctrine")->getManager();
- // Setting the current values before insert
- $this->jobNo = 'JIO19'.rand(100, 200);
- $this->setCreatedBy($currentUser);
- $this->setCreatedAt(new DateTime("now"));
- $this->setUpdatedBy($currentUser);
- $this->setUpdatedAt(new DateTime("now"));
- }
- /**
- * @ORM\PreUpdate
- */
- public function setUpdatedValues() {
- global $kernel;
- $container = $kernel->getContainer();
- $currentUser = $container->get('security.token_storage')->getToken()->getUser();
- $em = $container->get("doctrine")->getManager();
- // Updated At
- $this->setUpdatedAt(new DateTime("now"));
- $this->setUpdatedBy($currentUser);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement