<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Account
* @ORM\Table(name="account", indexes={@ORM\Index(name="ac_user", columns={"ac_user"})})
* @ORM\Entity(repositoryClass="App\Repository\AccountRepository")
* @ORM\HasLifecycleCallbacks
*/
class Account {
const ACCOUNT_STATUS_ACTIVE = 0;
const ACCOUNT_STATUS_INACTIVE = 1;
const COMPLETE_ACCOUNT = 0;
const INCOMPLETE_ACCOUNT = 1;
const LEAD_2_ACCOUNT = 2;
/**
* @var integer
* @ORM\Column(name="ac_id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
* @ORM\Column(name="ac_name", type="string", length=50, nullable=false)
*/
private $acName;
/**
* @var string
* @ORM\Column(name="ac_legal_name", type="string", length=50, nullable=false, options={"default":""})
*/
private $acLegalName = '';
/**
* @var string
* @ORM\Column(name="ac_nick_name", type="string", length=255, nullable=true, unique=true)
*/
private $acNickName;
/**
* @var string
* @ORM\Column(name="ac_phone_number", type="string", length=50, nullable=true)
*/
private $acPhoneNumber;
/**
* @var string
* @ORM\Column(name="ac_email", type="string", length=50, nullable=true)
*/
private $acEmail;
/**
* @var string
* @ORM\Column(name="ac_contact_name", type="string", length=50, nullable=true)
*/
private $acContactName;
/**
* @var \DateTime
* @ORM\Column(name="ac_date_created", type="datetime", nullable=true)
*/
private $acDateCreated;
/**
* @var \App\Entity\User
* @ORM\ManyToOne(targetEntity="App\Entity\User")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="ac_user", referencedColumnName="us_id", nullable=true, onDelete="CASCADE")
* })
*/
private $acUser;
/**
* @var string
* @ORM\Column(name="ac_suit_po_box", type="string", nullable=true)
*/
private $acSuitPoBox;
/**
* @var string
* @ORM\Column(name="ac_address", type="string", nullable=true)
*/
private $acAddress;
/**
* @var string
* @ORM\Column(name="ac_address_public", type="string", nullable=true)
*/
private $acAddressPublic;
/**
* @var \App\Entity\City
* @ORM\ManyToOne(targetEntity="App\Entity\City")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="ac_city_id", referencedColumnName="ci_id", nullable=true)
* })
*/
private $city;
/**
* @var \App\Entity\Zipcode
* @ORM\ManyToOne(targetEntity="App\Entity\Zipcode")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="ac_zip_code_id", referencedColumnName="zc_id", nullable=true)
* })
*/
private $zipcode;
/**
* @var string
* @ORM\Column(name="ac_deleted", type="boolean", nullable=false)
*/
private $deleted;
/**
* @var string
* @ORM\Column(name="omt_sync", type="guid", nullable=true)
*/
private $omtSync;
/**
* @var string
* @ORM\Column(name="ac_ein_number", type="string", length=20, nullable=true, unique=true)
*/
private $ein;
/**
* @var string
* @ORM\Column(name="ac_suite", type="string", length=100, nullable=true)
*/
private $suite;
/**
* @var smallint
* @ORM\Column(name="ac_number_locations", type="smallint", nullable=false, options={"default":1})
*/
private $numberLocations = 1;
/**
* @var string
* @ORM\Column(name="ac_internal_notes", type="string", length=250, nullable=true)
*/
private $internalNotes;
/**
* @var smallint
* @ORM\Column(name="ac_corporate_type_business", type="smallint", nullable=false, options={"default":1})
*/
private $corporateTypeBusiness = 1;
/**
* @var smallint
* @ORM\Column(name="ac_is_lead_account", type="smallint", nullable=false, options={"default":0})
*/
private $isLeadAccount = 0;
/**
* @var boolean
* @ORM\Column(name="ac_account_quote", type="boolean", nullable=false, options={"default":false})
*/
private $accountQuote = false;
/**
* @var boolean
* @ORM\Column(name="ac_is_testing", type="boolean", nullable=false, options={"default":false})
*/
private $isTesting = false;
/**
* @var \App\Entity\Company
* @ORM\ManyToOne(targetEntity="App\Entity\Company")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="company", referencedColumnName="co_id", nullable=true)
* })
*/
private $company;
/**
* @return type
*/
public function getOmtSync() {
return $this->omtSync;
}
/**
* @param type $omtSync
*/
public function setOmtSync($omtSync) {
$this->omtSync = $omtSync;
}
/**
* @return type
*/
public function getId() {
return $this->id;
}
/**
* @return type
*/
public function getAcName() {
return $this->acName;
}
/**
* @return type
*/
public function getAcLegalName() {
return $this->acLegalName;
}
/**
* @return type
*/
public function getAcPhoneNumber() {
return $this->acPhoneNumber;
}
/**
* @return type
*/
public function getAcEmail() {
return $this->acEmail;
}
/**
* @return type
*/
public function getAcContactName() {
return $this->acContactName;
}
/**
* @return type
*/
public function getAcDateCreated() {
return $this->acDateCreated;
}
/**
* @return type
*/
public function getAcUser() {
return $this->acUser;
}
/**
* @param type $acName
*/
public function setAcName($acName) {
$this->acName = $acName;
}
/**
* @param type $acLegalName
*/
public function setAcLegalName($acLegalName) {
$this->acLegalName = $acLegalName;
}
/**
* @param type $acPhoneNumber
*/
public function setAcPhoneNumber($acPhoneNumber) {
$this->acPhoneNumber = $acPhoneNumber;
}
/**
* @param type $acEmail
*/
public function setAcEmail($acEmail) {
$this->acEmail = $acEmail;
}
/**
* @param type $acContactName
*/
public function setAcContactName($acContactName) {
$this->acContactName = $acContactName;
}
/**
* @param \DateTime $acDateCreated
*/
public function setAcDateCreated(\DateTime $acDateCreated = NULL) {
$this->acDateCreated = $acDateCreated;
}
/**
* @param \App\Entity\User $acUser
*/
public function setAcUser(\App\Entity\User $acUser = null) {
$this->acUser = $acUser;
}
/**
* @return type
*/
public function __toString() {
return "" . $this->acName;
}
/**
* @return type
*/
public function getDeleted() {
return $this->deleted;
}
/**
* @param type $deleted
*/
public function setDeleted($deleted) {
$this->deleted = $deleted;
}
/**
* @param type $acNickName
*/
public function setAcNickName($acNickName) {
$this->acNickName = $acNickName;
}
/**
* @return type
*/
public function getAcNickName() {
return $this->acNickName;
}
/**
* @ORM\PrePersist
*/
public function defaultDeleted() {
$this->deleted = false;
}
/**
* @return string
*/
public function accountStatus() {
if (!$this->getDeleted()) {
return 'Active';
} else {
return 'Inactive';
}
}
/**
* @return type
*/
public function getAcSuitPoBox() {
return $this->acSuitPoBox;
}
/**
* @return type
*/
public function getAcAddress() {
return $this->acAddress;
}
/**
* @return type
*/
public function getCity() {
return $this->city;
}
/**
* @return type
*/
public function getZipcode() {
return $this->zipcode;
}
/**
* @param type $acSuiPoBox
*/
public function setAcSuitPoBox($acSuiPoBox) {
$this->acSuitPoBox = $acSuiPoBox;
}
/**
* @param type $acAddress
*/
public function setAcAddress($acAddress) {
$this->acAddress = $acAddress;
}
/**
* @param \App\Entity\City $acCitiId
*/
public function setCity(\App\Entity\City $acCitiId) {
$this->city = $acCitiId;
}
/**
* @param \App\Entity\Zipcode $zipcode
*/
public function setZipcode(\App\Entity\Zipcode $zipcode) {
$this->zipcode = $zipcode;
}
/**
* @author Aealan Z <lrobledo@kijho.com> 29/07/2016
* @param type $alias slachichas y mas
* @param type $search
* @return type
*/
public static function filterSearchParameters($alias, $search) {
$textParameters = '';
$parameters = [];
if (isset($search ['acName']) && $search ['acName'] != '') {
$textParameters .= " AND " . $alias . ".acName LIKE :acName";
$parameters ['acName'] = "%" . $search ['acName'] . "%";
}
if (isset($search ['acContactName']) && $search ['acContactName'] != '') {
$textParameters .= " AND " . $alias . ".acContactName LIKE :acContactName";
$parameters ['acContactName'] = "%" . $search ['acContactName'] . "%";
}
if (isset($search ['acEmail']) && $search ['acEmail'] != '') {
$textParameters .= " AND " . $alias . ".acEmail LIKE :acEmail";
$parameters ['acEmail'] = "%" . $search ['acEmail'] . "%";
}
if (isset($search ['deleted']) && $search ['deleted'] != '') {
$textParameters .= " AND " . $alias . ".deleted = :deleted";
$parameters ['deleted'] = $search ['deleted'];
}
if (isset($search ['acUser']) && $search ['acUser'] != '') {
$textParameters .= " AND " . $alias . ".acUser = :acUser";
$parameters ['acUser'] = $search ['acUser'];
}
if (isset($search['user']) && $search['user'] instanceof User && $search['user']->getUsType() != User::USER_SUPER_ADMIN && $search['user']->getUsType() != User::USER_INTERNAL_SUPPORT) {
if ($search['user']->getUsType() == User::USER_RESELLER) {
$textParameters .= " AND $alias.acUser IN (SELECT US.id FROM App\Entity\User US WHERE US.usType IN ('". User::USER_RESELLER ."','". User::USER_SUB_RESELLER ."','". User::USER_SUB_SUB_RESELLER ."')) ";
}elseif($search['user']->getUsType() == User::USER_SUB_RESELLER){
$textParameters .= " AND $alias.acUser IN (SELECT US.id FROM App\Entity\User US WHERE US.usType IN ('". User::USER_SUB_RESELLER ."','". User::USER_SUB_SUB_RESELLER ."')) ";
}elseif($search['user']->getUsType() == User::USER_SUB_SUB_RESELLER){
$textParameters .= " AND $alias.acUser IN (SELECT US.id FROM App\Entity\User US WHERE US.usType = ". User::USER_SUB_SUB_RESELLER .") ";
}
}
return ['text' => $textParameters, 'parameters' => $parameters];
}
/**
* @author Aealan Z <lrobledo@kijho.com> 29/07/2016
* @param type $alias slachichas y mas
* @param type $order
* @return string
*/
public static function filterOrderParameters($alias, $order) {
$orderBy = ' ORDER BY ' . $alias . '.acName ASC';
if (isset($order ['order_by_contac_name']) && $order ['order_by_contac_name'] != '') {
if ($order ['order_by_contac_name'] % 2) {
$orderBy = " ORDER BY " . $alias . ".acContactName DESC";
} else {
$orderBy = " ORDER BY " . $alias . ".acContactName ASC";
}
} elseif (isset($order ['order_by_account_email']) && $order ['order_by_account_email'] != '') {
if ($order ['order_by_account_email'] % 2) {
$orderBy = " ORDER BY " . $alias . ".acEmail DESC";
} else {
$orderBy = " ORDER BY " . $alias . ".acEmail ASC";
}
} elseif (isset($order ['order_by_account_name']) && $order ['order_by_account_name'] != '') {
if ($order ['order_by_account_name'] % 2) {
$orderBy = " ORDER BY " . $alias . ".acName DESC";
} else {
$orderBy = " ORDER BY " . $alias . ".acName ASC";
}
} elseif (isset($order ['order_by_created_date']) && $order ['order_by_created_date'] != '') {
if ($order ['order_by_created_date'] % 2) {
$orderBy = " ORDER BY " . $alias . ".acDateCreated DESC";
} else {
$orderBy = " ORDER BY " . $alias . ".acDateCreated ASC";
}
}
return $orderBy;
}
/**
* Get the value of ein
*/
public function getEin(){
return $this->ein;
}
/**
* Set the value of ein
*/
public function setEin($ein){
$this->ein = $ein;
}
/**
* Get the value of suite
*/
public function getSuite(){
return $this->suite;
}
/**
* Set the value of suite
*/
public function setSuite($suite){
$this->suite = $suite;
}
/**
* Get the value of internalNotes
*/
public function getInternalNotes(){
return $this->internalNotes;
}
/**
* Set the value of internalNotes
*/
public function setInternalNotes($internalNotes){
$this->internalNotes = $internalNotes;
}
/**
* Get the value of corporateTypeBusiness
*/
public function getCorporateTypeBusiness(){
return $this->corporateTypeBusiness;
}
/**
* Set the value of corporateTypeBusiness
*/
public function setCorporateTypeBusiness(string $corporateTypeBusiness){
$this->corporateTypeBusiness = $corporateTypeBusiness;
}
public function showEverything() {
return get_object_vars($this);
}
/**
* Get the value of isLeadAccount
*/
public function getIsLeadAccount()
{
return $this->isLeadAccount;
}
/**
* Set the value of isLeadAccount
* @param $isLeadAccount
*/
public function setIsLeadAccount($isLeadAccount)
{
$this->isLeadAccount = $isLeadAccount;
}
/**
* Get the value of numberLocations
*/
public function getNumberLocations(){
return $this->numberLocations;
}
/**
* Set the value of numberLocations
*/
public function setNumberLocations($numberLocations){
$this->numberLocations = $numberLocations;
}
/**
* Get the value of acAddressPublic
* @return string
*/
public function getAcAddressPublic(){
return $this->acAddressPublic;
}
/**
* Set the value of acAddressPublic
* @param string $acAddressPublic
*/
public function setAcAddressPublic(string $acAddressPublic){
$this->acAddressPublic = $acAddressPublic;
}
/**
* Get the value of accountQuote
*/
public function getAccountQuote(){
return $this->accountQuote;
}
/**
* Set the value of accountQuote
*/
public function setAccountQuote($accountQuote){
$this->accountQuote = $accountQuote;
}
/**
* Get the value of isTesting
* @return boolean
*/
public function getIsTesting()
{
return $this->isTesting;
}
/**
* Set the value of isTesting
* @param bool $isTesting
*/
public function setIsTesting(bool $isTesting)
{
$this->isTesting = $isTesting;
}
/**
* Get Company
*/
public function getCompany(){
return $this->company;
}
/**
* Set Company
*/
public function setCompany($company){
$this->company = $company;
}
}