Add Notification entity. Modify User and JobOrder entities for notifications. #433
This commit is contained in:
parent
9717effb0a
commit
0b8b462f8f
3 changed files with 179 additions and 0 deletions
|
|
@ -346,6 +346,12 @@ class JobOrder
|
||||||
*/
|
*/
|
||||||
protected $date_status_change;
|
protected $date_status_change;
|
||||||
|
|
||||||
|
// notifications for this job order
|
||||||
|
/**
|
||||||
|
* @ORM\OneToMany(targetEntity="Notification", mappedBy="job_order")
|
||||||
|
*/
|
||||||
|
protected $jo_notifications;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->date_create = new DateTime();
|
$this->date_create = new DateTime();
|
||||||
|
|
@ -368,6 +374,8 @@ class JobOrder
|
||||||
$this->meta = [];
|
$this->meta = [];
|
||||||
|
|
||||||
$this->phone_mobile = '';
|
$this->phone_mobile = '';
|
||||||
|
|
||||||
|
$this->jo_notifications = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getID()
|
public function getID()
|
||||||
|
|
@ -996,4 +1004,9 @@ class JobOrder
|
||||||
return $this->jo_extra;
|
return $this->jo_extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getNotifications()
|
||||||
|
{
|
||||||
|
return $this->jo_notifications;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
134
src/Entity/Notification.php
Normal file
134
src/Entity/Notification.php
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
<?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 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 getNotficationTypeName()
|
||||||
|
{
|
||||||
|
return NotificationType::getName($this->notif_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -110,6 +110,18 @@ class User extends BaseUser implements Serializable
|
||||||
*/
|
*/
|
||||||
protected $partners_created;
|
protected $partners_created;
|
||||||
|
|
||||||
|
// notifications for this user
|
||||||
|
/**
|
||||||
|
* @ORM\OneToMany(targetEntity="Notification", mappedBy="user", indexBy="id")
|
||||||
|
*/
|
||||||
|
protected $user_notifications;
|
||||||
|
|
||||||
|
// flag to check if user has read notifications
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="boolean")
|
||||||
|
*/
|
||||||
|
protected $flag_read_notifications;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
@ -119,6 +131,9 @@ class User extends BaseUser implements Serializable
|
||||||
$this->job_orders_assigned = new ArrayCollection();
|
$this->job_orders_assigned = new ArrayCollection();
|
||||||
$this->tickets = new ArrayCollection();
|
$this->tickets = new ArrayCollection();
|
||||||
$this->partners_created = new ArrayCollection();
|
$this->partners_created = new ArrayCollection();
|
||||||
|
$this->user_notifications = new ArrayCollection();
|
||||||
|
|
||||||
|
$this->flag_read_notifications = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getID()
|
public function getID()
|
||||||
|
|
@ -309,4 +324,21 @@ class User extends BaseUser implements Serializable
|
||||||
{
|
{
|
||||||
return $this->partners_created;
|
return $this->partners_created;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getNotifications()
|
||||||
|
{
|
||||||
|
return $this->user_notifications;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isNotificationsRead()
|
||||||
|
{
|
||||||
|
return $this->flag_read_notifications;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setReadNotifications($bool = true)
|
||||||
|
{
|
||||||
|
$this->flag_read_notifications = $bool;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue