145 lines
2.7 KiB
PHP
145 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
use App\Ramcar\NotificationType;
|
|
|
|
use DateTime;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="notification")
|
|
*/
|
|
class Notification
|
|
{
|
|
// unique id
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\Column(type="integer")
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
protected $id;
|
|
|
|
// message
|
|
/**
|
|
* @ORM\Column(type="string", length=80, nullable=true)
|
|
*/
|
|
protected $message;
|
|
|
|
// date notification was created
|
|
/**
|
|
* @ORM\Column(type="datetime")
|
|
*/
|
|
protected $date_create;
|
|
|
|
// has it been read, if yes, true.
|
|
/**
|
|
* @ORM\Column(type="boolean")
|
|
*/
|
|
protected $flag_read;
|
|
|
|
// user that created the job order
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="user_notifications")
|
|
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
|
|
*/
|
|
protected $user;
|
|
|
|
// job order in notification
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="JobOrder", inversedBy="jo_notifications")
|
|
* @ORM\JoinColumn(name="jo_id", referencedColumnName="id")
|
|
*/
|
|
protected $job_order;
|
|
|
|
// notification_type
|
|
/**
|
|
* @ORM\Column(type="string", length=25, nullable=true)
|
|
*/
|
|
protected $notif_type;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->flag_read = false;
|
|
$this->date_create = new DateTime();
|
|
}
|
|
|
|
public function getID()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function setDateCreate(DateTime $date_create)
|
|
{
|
|
$this->date_create = $date_create;
|
|
return $this;
|
|
}
|
|
|
|
public function getDateCreate()
|
|
{
|
|
return $this->date_create;
|
|
}
|
|
|
|
public function setMessage($message)
|
|
{
|
|
$this->message = $message;
|
|
return $this;
|
|
}
|
|
|
|
public function getMessage()
|
|
{
|
|
return $this->message;
|
|
}
|
|
|
|
public function isNotificationRead()
|
|
{
|
|
return $this->flag_read;
|
|
}
|
|
|
|
public function setReadNotification($bool = true)
|
|
{
|
|
$this->flag_read = $bool;
|
|
return $this;
|
|
}
|
|
|
|
public function setUser(User $user)
|
|
{
|
|
$this->user = $user;
|
|
return $this;
|
|
}
|
|
|
|
public function getUser()
|
|
{
|
|
return $this->user;
|
|
}
|
|
|
|
public function setJobOrder(JobOrder $jo)
|
|
{
|
|
$this->job_order = $jo;
|
|
return $this;
|
|
}
|
|
|
|
public function getJobOrder()
|
|
{
|
|
return $this->job_order;
|
|
}
|
|
|
|
public function setNotificationType($notif_type)
|
|
{
|
|
$this->notif_type = $notif_type;
|
|
return $this;
|
|
}
|
|
|
|
public function getNotificationType()
|
|
{
|
|
return $this->notif_type;
|
|
}
|
|
|
|
public function getNotificationTypeName()
|
|
{
|
|
return NotificationType::getName($this->notif_type);
|
|
}
|
|
|
|
}
|