382 lines
7.6 KiB
PHP
382 lines
7.6 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
use App\Ramcar\CustomerClassification;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="customer")
|
|
*/
|
|
class Customer
|
|
{
|
|
// unique id
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\Column(type="integer")
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
protected $id;
|
|
|
|
// title
|
|
/**
|
|
* @ORM\Column(type="string", length=80)
|
|
*/
|
|
protected $title;
|
|
|
|
// 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=65535)
|
|
*/
|
|
protected $customer_notes;
|
|
|
|
// mobile numbers linked to this customer
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="MobileNumber", mappedBy="customer", cascade={"persist"})
|
|
*/
|
|
// protected $numbers;
|
|
|
|
// mobile phone
|
|
/**
|
|
* @ORM\Column(type="string", length=30)
|
|
*/
|
|
protected $phone_mobile;
|
|
|
|
// landline
|
|
/**
|
|
* @ORM\Column(type="string", length=30)
|
|
*/
|
|
protected $phone_landline;
|
|
|
|
// office phone
|
|
/**
|
|
* @ORM\Column(type="string", length=30)
|
|
*/
|
|
protected $phone_office;
|
|
|
|
// fax
|
|
/**
|
|
* @ORM\Column(type="string", length=30)
|
|
*/
|
|
protected $phone_fax;
|
|
|
|
// 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;
|
|
|
|
// if active
|
|
/**
|
|
* @ORM\Column(type="boolean")
|
|
*/
|
|
protected $flag_active;
|
|
|
|
/**
|
|
* @ORM\Column(type="string", length=80)
|
|
*/
|
|
protected $email;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->numbers = new ArrayCollection();
|
|
$this->sessions = new ArrayCollection();
|
|
$this->vehicles = new ArrayCollection();
|
|
$this->job_orders = new ArrayCollection();
|
|
|
|
$this->customer_classification = CustomerClassification::REGULAR;
|
|
$this->customer_notes = '';
|
|
$this->title = '';
|
|
|
|
$this->flag_confirmed = false;
|
|
$this->flag_mobile_app = false;
|
|
$this->flag_active = true;
|
|
|
|
$this->phone_mobile = '';
|
|
$this->phone_landline = '';
|
|
$this->phone_office = '';
|
|
$this->phone_fax = '';
|
|
|
|
$this->email = '';
|
|
}
|
|
|
|
public function getID()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function setTitle($title)
|
|
{
|
|
$this->title = $title;
|
|
return $this;
|
|
}
|
|
|
|
public function getTitle()
|
|
{
|
|
return $this->title;
|
|
}
|
|
|
|
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 getMobileNumberList()
|
|
{
|
|
$phones = [];
|
|
|
|
if (!empty($this->phone_mobile))
|
|
$phones[] = '+63' . $this->phone_mobile;
|
|
|
|
if (!empty($this->phone_landline))
|
|
$phones[] = '+63' . $this->phone_landline;
|
|
|
|
if (!empty($this->phone_office))
|
|
$phones[] = '+63' . $this->phone_office;
|
|
|
|
if (!empty($this->phone_fax))
|
|
$phones[] = '+63' . $this->phone_fax;
|
|
|
|
return $phones;
|
|
}
|
|
|
|
public function setPhoneMobile($phone)
|
|
{
|
|
$this->phone_mobile = $phone;
|
|
return $this;
|
|
}
|
|
|
|
public function getPhoneMobile()
|
|
{
|
|
return $this->phone_mobile;
|
|
}
|
|
|
|
public function setPhoneLandline($phone)
|
|
{
|
|
$this->phone_landline = $phone;
|
|
return $this;
|
|
}
|
|
|
|
public function getPhoneLandline()
|
|
{
|
|
return $this->phone_landline;
|
|
}
|
|
|
|
public function setPhoneOffice($phone)
|
|
{
|
|
$this->phone_office = $phone;
|
|
return $this;
|
|
}
|
|
|
|
public function getPhoneOffice()
|
|
{
|
|
return $this->phone_office;
|
|
}
|
|
|
|
public function setPhoneFax($phone)
|
|
{
|
|
$this->phone_fax = $phone;
|
|
return $this;
|
|
}
|
|
|
|
public function getPhoneFax()
|
|
{
|
|
return $this->phone_fax;
|
|
}
|
|
|
|
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 removeVehicle($vehicle)
|
|
{
|
|
$this->vehicles->removeElement($vehicle);
|
|
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 setActive($flag_active = true)
|
|
{
|
|
$this->flag_active = $flag_active;
|
|
return $this;
|
|
}
|
|
|
|
public function isActive()
|
|
{
|
|
return $this->flag_active;
|
|
}
|
|
|
|
public function getJobOrders()
|
|
{
|
|
return $this->job_orders;
|
|
}
|
|
|
|
public function getTickets()
|
|
{
|
|
return $this->tickets;
|
|
}
|
|
|
|
public function setEmail($email)
|
|
{
|
|
$this->email = $email;
|
|
return $this;
|
|
}
|
|
|
|
public function getEmail()
|
|
{
|
|
return $this->email;
|
|
}
|
|
}
|