721 lines
15 KiB
PHP
721 lines
15 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 DateTime;
|
|
|
|
use App\Ramcar\CustomerClassification;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="customer", indexes={
|
|
* @ORM\Index(name="phone_mobile_idx", columns={"phone_mobile"}),
|
|
* @ORM\Index(columns={"first_name"}, flags={"fulltext"}),
|
|
* @ORM\Index(columns={"last_name"}, flags={"fulltext"})
|
|
* })
|
|
*/
|
|
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;
|
|
|
|
// link to customer user
|
|
/**
|
|
* @ORM\OneToOne(targetEntity="CustomerUser", inversedBy="customer")
|
|
* @ORM\JoinColumn(name="customer_user_id", referencedColumnName="id", nullable=true)
|
|
*/
|
|
protected $customer_user;
|
|
|
|
// 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;
|
|
|
|
// csat
|
|
/**
|
|
* @ORM\Column(type="boolean")
|
|
*/
|
|
protected $flag_csat;
|
|
|
|
/**
|
|
* @ORM\Column(type="string", length=80)
|
|
*/
|
|
protected $email;
|
|
|
|
/**
|
|
* @ORM\Column(type="boolean")
|
|
*/
|
|
protected $priv_third_party;
|
|
|
|
/**
|
|
* @ORM\Column(type="boolean")
|
|
*/
|
|
protected $priv_promo;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="PrivacyPolicy", inversedBy="cust_mobile_app")
|
|
* @ORM\JoinColumn(name="policy_mobile_app_id", referencedColumnName="id")
|
|
*/
|
|
protected $privpol_mobile_app;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="PrivacyPolicy", inversedBy="cust_third_party")
|
|
* @ORM\JoinColumn(name="policy_third_party_id", referencedColumnName="id")
|
|
*/
|
|
protected $privpol_third_party;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="PrivacyPolicy", inversedBy="cust_promo")
|
|
* @ORM\JoinColumn(name="policy_promo_id", referencedColumnName="id")
|
|
*/
|
|
protected $privpol_promo;
|
|
|
|
/**
|
|
* @ORM\Column(type="boolean", options={"default":false})
|
|
*/
|
|
protected $flag_promo_email;
|
|
|
|
/**
|
|
* @ORM\Column(type="boolean", options={"default":false})
|
|
*/
|
|
protected $flag_promo_sms;
|
|
|
|
/**
|
|
* @ORM\Column(type="boolean", options={"default":false})
|
|
*/
|
|
protected $flag_dpa_consent;
|
|
|
|
// date customer was created
|
|
/**
|
|
* @ORM\Column(type="datetime")
|
|
*/
|
|
protected $date_create;
|
|
|
|
/**
|
|
* @ORM\Column(type="boolean", options={"default":false})
|
|
*/
|
|
protected $flag_research_sms;
|
|
|
|
/**
|
|
* @ORM\Column(type="boolean", options={"default":false})
|
|
*/
|
|
protected $flag_research_email;
|
|
|
|
// where customer was created from
|
|
/**
|
|
* @ORM\Column(type="string", length=80, options={"default": "legacy"})
|
|
*/
|
|
protected $create_source;
|
|
|
|
/**
|
|
* @ORM\Column(type="integer", options={"unsigned": true, "default":0})
|
|
*/
|
|
protected $credits;
|
|
|
|
// customer tags
|
|
/**
|
|
* @ORM\ManyToMany(targetEntity="CustomerTag", inversedBy="customers", indexBy="id")
|
|
* @ORM\JoinTable(name="customer_customer_tags")
|
|
*/
|
|
protected $customer_tags;
|
|
|
|
// customer car club hub
|
|
/**
|
|
* One customer has one car club customer info
|
|
* @ORM\OneToOne(targetEntity="CarClubCustomerHub")
|
|
*/
|
|
protected $car_club_customer_hub;
|
|
|
|
// ratings made by customer
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="RiderRating", mappedBy="customer")
|
|
*/
|
|
protected $ratings;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->numbers = new ArrayCollection();
|
|
$this->sessions = new ArrayCollection();
|
|
$this->vehicles = new ArrayCollection();
|
|
$this->job_orders = new ArrayCollection();
|
|
$this->customer_tags = 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 = '';
|
|
|
|
$this->priv_third_party = 0;
|
|
$this->priv_promo = 0;
|
|
|
|
$this->flag_csat = false;
|
|
|
|
$this->flag_promo_email = false;
|
|
$this->flag_promo_sms = false;
|
|
$this->flag_dpa_consent = false;
|
|
$this->flag_research_sms = false;
|
|
$this->flag_research_email = false;
|
|
|
|
$this->date_create = new DateTime();
|
|
|
|
$this->create_source = 'unknown';
|
|
|
|
$this->ratings = new ArrayCollection();
|
|
|
|
$this->credits = 0;
|
|
}
|
|
|
|
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 getNameDisplay()
|
|
{
|
|
return $this->first_name . ' ' . $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[] = $this->phone_mobile;
|
|
|
|
if (!empty($this->phone_landline))
|
|
$phones[] = $this->phone_landline;
|
|
|
|
if (!empty($this->phone_office))
|
|
$phones[] = $this->phone_office;
|
|
|
|
if (!empty($this->phone_fax))
|
|
$phones[] = $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 setIsCSAT($bool = true)
|
|
{
|
|
$this->flag_csat = $bool;
|
|
return $this;
|
|
}
|
|
|
|
public function isCSAT()
|
|
{
|
|
return $this->flag_csat;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
public function setPrivacyThirdParty($bool = true)
|
|
{
|
|
$this->priv_third_party = $bool;
|
|
return $this;
|
|
}
|
|
|
|
public function getPrivacyThirdParty()
|
|
{
|
|
return $this->priv_third_party;
|
|
}
|
|
|
|
public function setPrivacyPromo($bool = true)
|
|
{
|
|
$this->priv_promo = $bool;
|
|
return $this;
|
|
}
|
|
|
|
public function getPrivacyPromo()
|
|
{
|
|
return $this->priv_promo;
|
|
}
|
|
|
|
public function setPrivacyPolicyMobile($privpol_mobile_app)
|
|
{
|
|
$this->privpol_mobile_app = $privpol_mobile_app;
|
|
return $this;
|
|
}
|
|
|
|
public function getPrivacyPolicyMobile()
|
|
{
|
|
return $this->privpol_mobile_app;
|
|
}
|
|
|
|
public function setPrivacyPolicyThirdParty($privpol_third_party)
|
|
{
|
|
$this->privpol_third_party = $privpol_third_party;
|
|
return $this;
|
|
}
|
|
|
|
public function getPrivacyPolicyThirdParty()
|
|
{
|
|
return $this->privpol_third_party;
|
|
}
|
|
|
|
public function setPrivacyPolicyPromo($privpol_promo)
|
|
{
|
|
$this->privpol_promo = $privpol_promo;
|
|
return $this;
|
|
}
|
|
|
|
public function getPrivacyPolicyPromo()
|
|
{
|
|
return $this->privpol_promo;
|
|
}
|
|
|
|
public function setPromoEmail($flag_promo_email = true)
|
|
{
|
|
$this->flag_promo_email = $flag_promo_email;
|
|
return $this;
|
|
}
|
|
|
|
public function isPromoEmail()
|
|
{
|
|
return $this->flag_promo_email;
|
|
}
|
|
|
|
public function setPromoSms($flag_promo_sms = true)
|
|
{
|
|
$this->flag_promo_sms = $flag_promo_sms;
|
|
return $this;
|
|
}
|
|
|
|
public function isPromoSms()
|
|
{
|
|
return $this->flag_promo_sms;
|
|
}
|
|
|
|
public function setDpaConsent($flag_dpa_consent = true)
|
|
{
|
|
$this->flag_dpa_consent = $flag_dpa_consent;
|
|
return $this;
|
|
}
|
|
|
|
public function isDpaConsent()
|
|
{
|
|
return $this->flag_dpa_consent;
|
|
}
|
|
|
|
public function setResearchSms($flag_research_sms = true)
|
|
{
|
|
$this->flag_research_sms = $flag_research_sms;
|
|
return $this;
|
|
}
|
|
|
|
public function isResearchSms()
|
|
{
|
|
return $this->flag_research_sms;
|
|
}
|
|
|
|
public function setResearchEmail($flag_research_email = true)
|
|
{
|
|
$this->flag_research_email = $flag_research_email;
|
|
return $this;
|
|
}
|
|
|
|
public function isResearchEmail()
|
|
{
|
|
return $this->flag_research_email;
|
|
}
|
|
|
|
public function setCreateSource($source)
|
|
{
|
|
$this->create_source = $source;
|
|
return $this;
|
|
}
|
|
|
|
public function getCreateSource()
|
|
{
|
|
return $this->create_source;
|
|
}
|
|
|
|
public function addCustomerTag(CustomerTag $customer_tag)
|
|
{
|
|
$this->customer_tags[$customer_tag->getID()] = $customer_tag;
|
|
return $this;
|
|
}
|
|
|
|
public function clearCustomerTags()
|
|
{
|
|
$this->customer_tags->clear();
|
|
return $this;
|
|
}
|
|
|
|
public function getCustomerTags()
|
|
{
|
|
$str_cust_tags = [];
|
|
foreach ($this->customer_tags as $cust_tag)
|
|
$str_cust_tags[] = $cust_tag->getID();
|
|
|
|
return $str_cust_tags;
|
|
}
|
|
|
|
public function getCustomerTagObjects()
|
|
{
|
|
return $this->customer_tags;
|
|
}
|
|
|
|
public function getCustomerTag($id)
|
|
{
|
|
if (isset($this->customer_tags[$id]))
|
|
return $this->customer_tags[$id];
|
|
|
|
return null;
|
|
}
|
|
|
|
public function removeCustomerTag(CustomerTag $customer_tag)
|
|
{
|
|
$this->customer_tags->removeElement($customer_tag);
|
|
$customer_tag->removeCustomer($this);
|
|
}
|
|
|
|
public function setCarClubCustomerHub(CarClubCustomerHub $car_club_customer_hub)
|
|
{
|
|
$this->car_club_customer_hub = $car_club_customer_hub;
|
|
return $this;
|
|
}
|
|
|
|
public function getCarClubCustomerHub()
|
|
{
|
|
return $this->car_club_customer_hub;
|
|
}
|
|
|
|
public function setCustomerUser(CustomerUser $cust_user = null)
|
|
{
|
|
$this->customer_user = $cust_user;
|
|
return $this;
|
|
}
|
|
|
|
public function getCustomerUser()
|
|
{
|
|
return $this->customer_user;
|
|
}
|
|
|
|
public function modifyCredits($amount)
|
|
{
|
|
$this->credits = bcadd($this->credits, $amount);
|
|
return $this;
|
|
}
|
|
|
|
public function getCredits()
|
|
{
|
|
return $this->credits;
|
|
}
|
|
}
|