resq/src/Entity/Customer.php
2018-01-31 23:55:16 +08:00

251 lines
5.1 KiB
PHP

<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Table(name="customer")
*/
class Customer
{
// unique id
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
// first name
/**
* @ORM\Column(type="string", length=80)
* @Assert\NotBlank()
*/
protected $first_name;
// last name
/**
* @ORM\Column(type="string", length=80)
* @Assert\NotBlank()
*/
protected $last_name;
// customer classification
/**
* @ORM\Column(type="string", length=80)
* @Assert\NotBlank()
*/
protected $customer_classification;
/**
* @ORM\Column(type="text", length=80)
*/
protected $customer_notes;
// mobile numbers linked to this customer
/**
* @ORM\OneToMany(targetEntity="MobileNumber", mappedBy="customer", cascade={"persist"})
*/
protected $numbers;
// mobile sessions linked to this customer
/**
* @ORM\OneToMany(targetEntity="MobileSession", mappedBy="customer")
*/
protected $sessions;
// vehicles linked to customer
/**
* @ORM\OneToMany(targetEntity="CustomerVehicle", mappedBy="customer", cascade={"persist"})
*/
protected $vehicles;
// job orders made by customer
/**
* @ORM\OneToMany(targetEntity="JobOrder", mappedBy="customer")
*/
protected $job_orders;
// tickets made by customer
/**
* @ORM\OneToMany(targetEntity="Ticket", mappedBy="customer")
*/
protected $tickets;
// if any of their mobile numbers have been confirmed
/**
* @ORM\Column(type="boolean")
*/
protected $flag_confirmed;
// if registered on mobile app
/**
* @ORM\Column(type="boolean")
*/
protected $flag_mobile_app;
public function __construct()
{
$this->numbers = new ArrayCollection();
$this->sessions = new ArrayCollection();
$this->vehicles = new ArrayCollection();
$this->job_orders = new ArrayCollection();
$this->flag_confirmed = false;
$this->flag_mobile_app = false;
}
public function getID()
{
return $this->id;
}
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 setCustomerClassification($customer_classification)
{
$this->customer_classification = $customer_classification;
return $this;
}
public function getCustomerClassification()
{
return $this->customer_classification;
}
public function setCustomerNotes($customer_notes)
{
$this->customer_notes = $customer_notes;
return $this;
}
public function getCustomerNotes()
{
return $this->customer_notes;
}
public function addMobileNumber(MobileNumber $number)
{
$this->numbers->add($number);
return $this;
}
public function clearMobileNumbers()
{
$this->numbers->clear();
return $this;
}
public function getMobileNumbers()
{
return $this->numbers;
}
public function getMobileNumberList()
{
$numbers = [];
foreach ($this->numbers as $number)
$numbers[] = $number->getID();
return $numbers;
}
public function getPlateNumberList()
{
$plate_numbers = [];
foreach ($this->vehicles as $vehicle)
$plate_numbers[] = $vehicle->getPlateNumber();
return $plate_numbers;
}
public function addMobileSession(MobileSession $session)
{
$this->sessions->add($session);
return $this;
}
public function clearMobileSessions()
{
$this->sessions->clear();
return $this;
}
public function getMobileSessions()
{
return $this->sessions;
}
public function addVehicle(CustomerVehicle $vehicle)
{
$this->vehicles->add($vehicle);
return $this;
}
public function clearVehicles()
{
$this->vehicles->clear();
return $this;
}
public function getVehicles()
{
return $this->vehicles;
}
public function setConfirmed($flag_confirmed = true)
{
$this->flag_confirmed = $flag_confirmed;
return $this;
}
public function isConfirmed()
{
return $this->flag_confirmed;
}
public function setHasMobileApp($flag_mobile_app = true)
{
$this->flag_mobile_app = $flag_mobile_app;
return $this;
}
public function hasMobileApp()
{
return $this->flag_mobile_app;
}
public function getJobOrders()
{
return $this->job_orders;
}
public function getTickets()
{
return $this->tickets;
}
}