246 lines
4.9 KiB
PHP
246 lines
4.9 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Ramcar\TicketType;
|
|
use App\Ramcar\TicketStatus;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
use DateTime;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="ticket")
|
|
*/
|
|
class Ticket
|
|
{
|
|
// unique id
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\Column(type="integer")
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
protected $id;
|
|
|
|
// date ticket was created
|
|
/**
|
|
* @ORM\Column(type="datetime")
|
|
*/
|
|
protected $date_create;
|
|
|
|
// status of the ticket
|
|
/**
|
|
* @ORM\Column(type="string", length=15)
|
|
* @Assert\NotBlank()
|
|
*/
|
|
protected $status;
|
|
|
|
// ticket type
|
|
/**
|
|
* @ORM\Column(type="string", length=15)
|
|
* @Assert\NotBlank()
|
|
*/
|
|
protected $ticket_type;
|
|
|
|
// user defined ticket type
|
|
/**
|
|
* @ORM\Column(type="string", length=80, nullable=true)
|
|
*/
|
|
protected $other_ticket_type;
|
|
|
|
// subject of this ticket
|
|
/**
|
|
* @ORM\Column(type="string", length=80)
|
|
* @Assert\NotBlank()
|
|
*/
|
|
protected $subject;
|
|
|
|
// first name of ticket owner
|
|
/**
|
|
* @ORM\Column(type="string", length=80)
|
|
* @Assert\NotBlank()
|
|
*/
|
|
protected $first_name;
|
|
|
|
// last name of ticket owner
|
|
/**
|
|
* @ORM\Column(type="string", length=80)
|
|
* @Assert\NotBlank()
|
|
*/
|
|
protected $last_name;
|
|
|
|
// contact number of ticket owner
|
|
/**
|
|
* @ORM\Column(type="string", length=20, nullable=true)
|
|
*/
|
|
protected $contact_num;
|
|
|
|
// details of this ticket
|
|
/**
|
|
* @ORM\Column(type="text", nullable=true)
|
|
*/
|
|
protected $details;
|
|
|
|
// user that created the ticket
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="tickets")
|
|
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
|
|
*/
|
|
protected $created_by;
|
|
|
|
// customer associated with the ticket (optional)
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="Customer", inversedBy="tickets")
|
|
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id", nullable=true)
|
|
*/
|
|
protected $customer;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->date_create = new DateTime();
|
|
}
|
|
|
|
public function getID()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function setDateCreate($date_create)
|
|
{
|
|
$this->date_create = $date_create;
|
|
return $this;
|
|
}
|
|
|
|
public function getDateCreate()
|
|
{
|
|
return $this->date_create;
|
|
}
|
|
|
|
public function setStatus($status)
|
|
{
|
|
$this->status = $status;
|
|
return $this;
|
|
}
|
|
|
|
public function getStatus()
|
|
{
|
|
return $this->status;
|
|
}
|
|
|
|
public function getStatusText()
|
|
{
|
|
$statuses = TicketStatus::getCollection();
|
|
return $statuses[$this->status] ?? "";
|
|
}
|
|
|
|
public function setTicketType($ticket_type)
|
|
{
|
|
$this->ticket_type = $ticket_type;
|
|
return $this;
|
|
}
|
|
|
|
public function getTicketType()
|
|
{
|
|
return $this->ticket_type;
|
|
}
|
|
|
|
public function setOtherTicketType($other_ticket_type)
|
|
{
|
|
$this->other_ticket_type = $other_ticket_type;
|
|
return $this;
|
|
}
|
|
|
|
public function getOtherTicketType()
|
|
{
|
|
return $this->other_ticket_type;
|
|
}
|
|
|
|
public function getTicketTypeText()
|
|
{
|
|
if ($this->ticket_type == TicketType::OTHER) {
|
|
return $this->other_ticket_type;
|
|
} else {
|
|
$types = TicketType::getCollection();
|
|
return $types[$this->ticket_type] ?? "";
|
|
}
|
|
}
|
|
|
|
public function setSubject($subject)
|
|
{
|
|
$this->subject = $subject;
|
|
return $this;
|
|
}
|
|
|
|
public function getSubject()
|
|
{
|
|
return $this->subject;
|
|
}
|
|
|
|
public function setFirstName($first_name)
|
|
{
|
|
$this->first_name = $first_name;
|
|
return $this;
|
|
}
|
|
|
|
public function getFirstName()
|
|
{
|
|
return $this->first_name;
|
|
}
|
|
|
|
public function setLastName($last_name)
|
|
{
|
|
$this->last_name = $last_name;
|
|
return $this;
|
|
}
|
|
|
|
public function getLastName()
|
|
{
|
|
return $this->last_name;
|
|
}
|
|
|
|
public function setContactNumber($num)
|
|
{
|
|
$this->contact_num = $num;
|
|
return $this;
|
|
}
|
|
|
|
public function getContactNumber()
|
|
{
|
|
return $this->contact_num;
|
|
}
|
|
|
|
public function setDetails($details)
|
|
{
|
|
$this->details = $details;
|
|
return $this;
|
|
}
|
|
|
|
public function getDetails()
|
|
{
|
|
return $this->details;
|
|
}
|
|
|
|
public function setCreatedBy(User $created_by)
|
|
{
|
|
$this->created_by = $created_by;
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedBy()
|
|
{
|
|
return $this->created_by;
|
|
}
|
|
|
|
public function setCustomer(Customer $customer)
|
|
{
|
|
$this->customer = $customer;
|
|
return $this;
|
|
}
|
|
|
|
public function getCustomer()
|
|
{
|
|
return $this->customer;
|
|
}
|
|
}
|