<?php
namespace App\AppBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\JoinTable;
use Knp\DoctrineBehaviors\Model as ORMBehaviors;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* User
*
* @ORM\Table(name="csps_user")
* @ORM\Entity(repositoryClass="App\AppBundle\Repository\UserRepository")
*/
class User implements UserInterface, \Serializable
{
//see role_hierarchy in security.yml to read show's rules
/*******/
/* MIB */
/*******/
/* IS INTERNAL */
const ROLE_MIB_CUSTOMER_CARE = 'ROLE_MIB_CUSTOMER_CARE';
const ROLE_DEALER_ADMIN = 'ROLE_DEALER_ADMIN';
//const ROLE_PSM = 'ROLE_PSM';
//const ROLE_INTERNAL = 'ROLE_INTERNAL';
const ROLE_MARKET_USER = 'ROLE_MARKET_USER';
const ROLE_MIB_CENTRAL_USER = 'ROLE_MIB_CENTRAL_USER';
const ROLE_MIB_PSD = 'ROLE_MIB_PSD';
const ROLE_PSD = 'ROLE_PSD';
const ROLE_KAM = 'ROLE_KAM';
/* ADMIN */
const ROLE_MIB_ADMIN = 'ROLE_MIB_ADMIN';
const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';
/* IS DEALER */
//const ROLE_DEALER = 'ROLE_DEALER';
const ROLE_DEALER_DSM = 'ROLE_DEALER_DSM';
//const ROLE_DP = 'ROLE_DP';
//const ROLE_DOP = 'ROLE_DOP';
const ROLE_WORKSHOP_MANAGER = 'ROLE_WORKSHOP_MANAGER';
const ROLE_PARTS_MANAGER = 'ROLE_PARTS_MANAGER';
const ROLE_GENERAL_MANAGER = 'ROLE_GENERAL_MANAGER';
const ROLE_PARTS_COUNTER = 'ROLE_PARTS_COUNTER';
const ROLE_SERVICE_ADVISOR = 'ROLE_SERVICE_ADVISOR';
/********/
/* ISOD */
/********/
/* IS INTERNAL */
const ROLE_INTERNAL = 'ROLE_INTERNAL';
const ROLE_PSM = 'ROLE_PSM';
/* ADMIN */
const ROLE_ADMIN = 'ROLE_ADMIN';
/* IS DEALER */
const ROLE_DP = 'ROLE_DP';
const ROLE_DEALER = 'ROLE_DEALER';
const ROLE_DOP = 'ROLE_DOP';
/* SPECIAL ROLES */
const ROLE_IS_INTERNAL = 'ROLE_IS_INTERNAL';
const ROLE_IS_DEALER = 'ROLE_IS_DEALER';
const DOP = 1;
const THIRD_PARTS = 2;
const PREDEFINED_ANALYSIS_OWNER_EMAIL = 'emea-next-contact@cnhind.com';
/**
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/** @ORM\Column(name="firstname", type="string") */
private $firstname;
/** @ORM\Column(name="lastname", type="string") */
private $lastname;
/**
* @var string
*
* @ORM\Column(name="username", type="string", length=28, unique=true)
*/
private $username;
/**
* @var string
*
* @ORM\Column(name="password", type="string", length=64, nullable=true)
*/
private $password;
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=60, unique=false, nullable=true)
*/
private $email;
/**
* @ORM\Column(name="is_active", type="boolean")
*/
private $isActive;
/**
* @var array
*
* @ORM\Column(type="simple_array")
*/
protected $roles;
/**
* @var array
*
* @ORM\Column(name="roles_myams", type="simple_array")
*/
protected $rolesMyAms;
/**
* Many Dealers have one DP
* @ORM\ManyToOne(targetEntity="User", fetch="EAGER")
* @ORM\JoinColumn(name="dealer_id", referencedColumnName="id",onDelete="CASCADE")
*
*/
private $dealerPrincipal;
/**
* @ORM\Column(name="last_login", type="datetime", nullable=true)
*/
private $lastLogin;
/**
* @ORM\Column(name="last_login_myams", type="datetime", nullable=true)
*/
private $lastLoginMyAms;
/**
* @ORM\Column(name="number_of_logins", type="integer")
*/
private $numberOfLogins = 0;
/**
* @ORM\Column(name="number_of_logins_myams", type="integer")
*/
private $numberOfLoginsMyAms = 0;
/**
* @ORM\ManyToMany(targetEntity="App\AppBundle\Entity\MacroDealer")
* @ORM\JoinTable(name="user_macrodealer",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id",onDelete="CASCADE")},
* inverseJoinColumns={@ORM\JoinColumn(name="macrodealer_id", referencedColumnName="id")}
* )
*/
private $macroDealers;
/**
* Many Users have One Warehouse.
* @ORM\ManyToMany(targetEntity="App\AppBundle\Entity\Warehouse")
* @ORM\JoinTable(name="user_warehouse",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id",onDelete="CASCADE")},
* inverseJoinColumns={@ORM\JoinColumn(name="warehouse_id", referencedColumnName="id")}
* )
* @ORM\OrderBy({"whId"="ASC"})
*/
private $warehouses;
/**
* Many Users have Many Countries.
* @ORM\ManyToMany(targetEntity="App\AppBundle\Entity\Country")
* @ORM\JoinTable(name="user_country",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id",onDelete="CASCADE")},
* inverseJoinColumns={@ORM\JoinColumn(name="country_id", referencedColumnName="id")}
* )
*
*/
private $countries;
/**
* Many users have one or null selectedCountry
* @ORM\ManyToOne(targetEntity="App\AppBundle\Entity\Country")
* @ORM\JoinColumn(name="selected_country", referencedColumnName="id",onDelete="CASCADE")
*/
private $selectedCountry;
/**
* Many users have one or null selectedMacroDealer
* @ORM\ManyToOne(targetEntity="App\AppBundle\Entity\MacroDealer")
* @ORM\JoinColumn(name="selected_macro_dealer", referencedColumnName="id",onDelete="CASCADE")
*/
private $selectedMacroDealer;
/**
* Many users have one or null selectedWarehouse
* @ORM\ManyToOne(targetEntity="App\AppBundle\Entity\Warehouse")
* @ORM\JoinColumn(name="selected_warehouse", referencedColumnName="id",onDelete="CASCADE")
*/
private $selectedWarehouses;
/**
* @var string
*
* @ORM\Column(name="selected_currency_code", type="string", length=7, nullable=true)
*/
private $selectedCurrencyCode;
/**
* @var int
*
* @ORM\Column(name="selected_macro_dealer_group", type="integer",nullable=true)
*/
private $selectedMacroDealerGroup;
/**
* @var string
*
* @ORM\Column(name="selected_locale", type="string", length=7, nullable=true)
*/
private $selectedLocale;
/** @ORM\Column(name="newsletter", type="boolean") */
private $newsletter;
/**
* @var boolean
* @ORM\Column(name="switch_to_old", type="boolean", options={"default":0})
*/
private $switchToOld = 0;
/**
* One User have many Log
* @ORM\OneToMany(targetEntity="App\AppBundle\Entity\Log", mappedBy="user",cascade={"REMOVE"})
*/
private $logs;
/**
* One User have Many login logs.
* @ORM\OneToMany(targetEntity="App\AppBundle\Entity\LoginLog", mappedBy="user",cascade={"REMOVE"})
*/
private $loginLogs;
/**
* Many Users have Many Panels.
* @ORM\ManyToMany(targetEntity="Coolshop\CoolDashboardBundle\Entity\CdbPanel")
* @ORM\JoinTable(name="user_cdb_panel",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id",onDelete="CASCADE")},
* inverseJoinColumns={@ORM\JoinColumn(name="cdb_panel_id", referencedColumnName="id")}
* )
*/
private $panels;
/**
* Many Users have Many Datasets.
* @ORM\ManyToMany(targetEntity="App\AppBundle\Entity\Dataset")
* @ORM\JoinTable(name="user_dataset",
* joinColumns={@JoinColumn(name="User_id", referencedColumnName="id",onDelete="CASCADE")},
* inverseJoinColumns={@JoinColumn(name="dataset_id", referencedColumnName="id")}
* )
*/
private $datasets;
/**
* One User have Many configurations.
* @ORM\OneToMany(targetEntity="App\AppBundle\Entity\Configuration", mappedBy="user",cascade={"REMOVE"})
*/
private $configurations;
/**
* @var boolean
* @ORM\Column(name="active_advanced_analytics", type="boolean", options={"default":0})
*/
private $activeAdvancedAnalytics;
/**
* @var boolean
* @ORM\Column(name="enable_predefined_analysis", type="boolean", options={"default":0})
*/
private $enablePredefinedAnalysisCreation;
/**
* @var string
*
* @ORM\Column(name="selected_brands", type="string", length=100, unique=false, nullable=true)
*/
private $selectedBrands;
/**
* @var boolean
* @ORM\Column(name="access_to_old", type="boolean", options={"default":1})
*/
private $accessToOld = true;
/**
* @var boolean
* @ORM\Column(name="access_to_new", type="boolean", options={"default":1})
*/
private $accessToNew = true;
/**
* @var boolean
* @ORM\Column(name="enable_sellout", type="boolean", options={"default":1})
*/
private $enableSellout = true;
/**
* @var boolean
* @ORM\Column(name="enable_dashboard", type="boolean", options={"default":1})
*/
private $enableDashboard = true;
/**
* @var boolean
* @ORM\Column(name="enable_sellin", type="boolean", options={"default":1})
*/
private $enableSellIn = true;
/**
* @var boolean
* @ORM\Column(name="enable_advanced_analytics", type="boolean", options={"default":1})
*/
private $enableAdvancedAnalytics = true;
/**
* @var boolean
* @ORM\Column(name="enable_stock_and_logistics", type="boolean", options={"default":1})
*/
private $enableStockAndLogistics = true;
/**
* @var boolean
* @ORM\Column(name="enable_take_rate", type="boolean", options={"default":1})
*/
private $enableTakeRate = true;
/**
* @var boolean
* @ORM\Column(name="enable_prim", type="boolean", options={"default":0})
*/
private $enablePrim = false;
/**
* @var boolean
* @ORM\Column(name="enable_user_edit", type="boolean", options={"default":0})
*/
private $enableUserEdit = false;
/**
* @var boolean
* @ORM\Column(name="enable_label_bulk_edit", type="boolean", options={"default":0})
*/
private $enableLabelBulkEdit = false;
// Just for edit profile table
private $market ;
private $dealerGroup;
private $dealership;
private $isEditMode;
// Just for menus
private $defaultUrl = null;
public function getRoles()
{
return $this->switchToOld ? $this->roles : $this->rolesMyAms;
}
public function getPrettyRole(){
return $this->roles[0];
}
public function getRolesIsod()
{
return $this->roles;
}
public function getRolesMyAms()
{
return $this->rolesMyAms;
}
public function getPrettyMyAmsRole(){
return $this->rolesMyAms[0];
}
public function eraseCredentials()
{
}
/** @see \Serializable::serialize() */
public function serialize()
{
return serialize(array(
$this->id,
$this->username,
$this->password,
$this->isActive
));
}
/** @see \Serializable::unserialize()
* @param string $serialized
*/
public function unserialize($serialized)
{
list (
$this->id,
$this->username,
$this->password,
$this->isActive
) = unserialize($serialized);
}
public function isAccountNonExpired()
{
return true;
}
public function isAccountNonLocked()
{
return true;
}
public function isCredentialsNonExpired()
{
return true;
}
public function getSalt()
{
return null;
}
public function isEnabled()
{
return $this->isActive;
}
/**
* Set firstname
*
* @param string $firstname
*
* @return User
*/
public function setFirstname($firstname)
{
$this->firstname = $firstname;
return $this;
}
/**
* Get firstname
*
* @return string
*/
public function getFirstname()
{
return $this->firstname;
}
/**
* Set lastname
*
* @param string $lastname
*
* @return User
*/
public function setLastname($lastname)
{
$this->lastname = $lastname;
return $this;
}
/**
* Get lastname
*
* @return string
*/
public function getLastname()
{
return $this->lastname;
}
public function getFullUsername() : string
{
$fullname = trim((!empty($this->firstname) ? $this->firstname : "") . " " . (!empty($this->lastname) ? $this->lastname : ""));
return !empty($fullname) ? ($this->username . " - " . $fullname) : $this->username;
}
/**
* Set username
*
* @param string $username
*
* @return User
*/
public function setUsername($username)
{
$this->username = $username;
return $this;
}
/**
* Get username
*
* @return string
*/
public function getUsername()
{
return $this->username;
}
/**
* Set password
*
* @param string $password
*
* @return User
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
/**
* Get password
*
* @return string
*/
public function getPassword()
{
return $this->password;
}
public function __toString()
{
return $this->getUsername()?:$this->getEmail();
}
/**
* @return bool
*/
public function isDealer()
{
return in_array(self::ROLE_DEALER, is_array($this->getRoles()) ? $this->getRoles() : array());
}
/**
* @return bool
*/
public function isDealerPrincipal()
{
return in_array(self::ROLE_DP, is_array($this->getRoles()) ? $this->getRoles() : array());
}
public function isDealerDOP()
{
return in_array(self::ROLE_DOP, is_array($this->getRoles()) ? $this->getRoles() : array());
}
public function isDealerPSM()
{
return in_array(self::ROLE_PSM, is_array($this->getRoles()) ? $this->getRoles() : array());
}
public function isWorkshopManager()
{
return in_array(self::ROLE_WORKSHOP_MANAGER, is_array($this->getRoles()) ? $this->getRoles() : array());
}
public function isPartsManager()
{
return in_array(self::ROLE_PARTS_MANAGER, is_array($this->getRoles()) ? $this->getRoles() : array());
}
public function isDealerDms()
{
return in_array(self::ROLE_DEALER_DSM, is_array($this->getRoles()) ? $this->getRoles() : array());
}
public function isGenearlManager()
{
return in_array(self::ROLE_GENERAL_MANAGER, is_array($this->getRoles()) ? $this->getRoles() : array());
}
public function isPartsCounter()
{
return in_array(self::ROLE_PARTS_COUNTER, is_array($this->getRoles()) ? $this->getRoles() : array());
}
public function isServiceAdvisor()
{
return in_array(self::ROLE_SERVICE_ADVISOR, is_array($this->getRoles()) ? $this->getRoles() : array());
}
/**
* @return bool
*/
public function hasDealerRole()
{
return $this->isDealer() ||
$this->isDealerPrincipal() ||
$this->isDealerDOP() ||
$this->isDealerPSM() ||
$this->isWorkshopManager() ||
$this->isPartsManager() ||
$this->isDealerDms() ||
$this->isGenearlManager() ||
$this->isPartsCounter() ||
$this->isServiceAdvisor();
}
/**
* @return bool
*/
public function hasDealerPrincipalRole()
{
return $this->isDealerPrincipal() || $this->isDealerDOP() || $this->isDealerPSM();
}
/**
* @return bool
*/
public function isCustomerCare()
{
return in_array(self::ROLE_MIB_CUSTOMER_CARE, is_array($this->getRoles()) ? $this->getRoles() : array());
}
public function isDealerAdmin(){
return in_array(self::ROLE_DEALER_ADMIN, is_array($this->getRoles()) ? $this->getRoles() : array());
}
public function isMarketUser(){
return in_array(self::ROLE_MARKET_USER, is_array($this->getRoles()) ? $this->getRoles() : array());
}
public function isPSD(){
return in_array(self::ROLE_PSD, is_array($this->getRoles()) ? $this->getRoles() : array());
}
public function isKAM(){
return in_array(self::ROLE_KAM, is_array($this->getRoles()) ? $this->getRoles() : array());
}
/**
* @return bool
*/
public function isInternal()
{
return in_array(self::ROLE_INTERNAL, is_array($this->getRoles()) ? $this->getRoles() : array());
}
public function hasInternalRole()
{
return $this->isInternal() || $this->isMarketUser() || $this->isPSD() || $this->isKAM();
}
/**
* @return bool
*/
public function isAdmin()
{
return in_array(self::ROLE_ADMIN, is_array($this->getRoles()) ? $this->getRoles() : array()) ||
in_array(self::ROLE_SUPER_ADMIN, is_array($this->getRoles()) ? $this->getRoles() : array()) ||
in_array(self::ROLE_MIB_ADMIN, is_array($this->getRoles()) ? $this->getRoles() : array());
}
/* autogenerated */
/**
* Constructor
*/
public function __construct()
{
$this->warehouses = new \Doctrine\Common\Collections\ArrayCollection();
$this->logs = new \Doctrine\Common\Collections\ArrayCollection();
$this->panels = new \Doctrine\Common\Collections\ArrayCollection();
$this->loginLogs = new \Doctrine\Common\Collections\ArrayCollection();
//$this->market = new \Doctrine\Common\Collections\ArrayCollection();
//$this->dealerGroup = new \Doctrine\Common\Collections\ArrayCollection();
//$this->dealership = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set email
*
* @param string $email
*
* @return User
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set isActive
*
* @param boolean $isActive
*
* @return User
*/
public function setIsActive($isActive)
{
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive
*
* @return boolean
*/
public function getIsActive()
{
return $this->isActive;
}
/**
* Set roles
*
* @param array $roles
*
* @return User
*/
public function setRoles($roles)
{
$this->roles = $roles;
return $this;
}
/**
* Set rolesMyAms
*
* @param array $rolesMyAms
*
* @return User
*/
public function setRolesMyAms($rolesMyAms)
{
$this->rolesMyAms = $rolesMyAms;
return $this;
}
/**
* Set lastLogin
*
* @param \DateTime $lastLogin
*
* @return User
*/
public function setLastLogin($lastLogin)
{
$this->lastLogin = $lastLogin;
return $this;
}
/**
* Set lastLoginMyAms
*
* @param \DateTime $lastLoginMyAms
*
* @return User
*/
public function setlastLoginMyAms($lastLogin)
{
$this->lastLoginMyAms = $lastLogin;
return $this;
}
/**
* Get lastLogin
*
* @return \DateTime
*/
public function getLastLogin()
{
return $this->lastLogin;
}
/**
* Get lastLoginMyAms
*
* @return \DateTime
*/
public function getlastLoginMyAms()
{
return $this->lastLoginMyAms;
}
/**
* Set numberOfLogins
*
* @param integer $numberOfLogins
*
* @return User
*/
public function setNumberOfLogins($numberOfLogins)
{
$this->numberOfLogins = $numberOfLogins;
return $this;
}
/**
* Get numberOfLogins
*
* @return integer
*/
public function getNumberOfLogins()
{
return $this->numberOfLogins;
}
/**
* Set numberOfLoginsMyAms
*
* @param integer $numberOfLoginsMyAms
*
* @return User
*/
public function setNumberOfLoginsMyAms($numberOfLoginsMyAms)
{
$this->numberOfLoginsMyAms = $numberOfLoginsMyAms;
return $this;
}
/**
* Get numberOfLoginsMyAms
*
* @return integer
*/
public function getNumberOfLoginsMyAms()
{
return $this->numberOfLoginsMyAms;
}
/**
* Set selectedCurrencyCode
*
* @param string $selectedCurrencyCode
*
* @return User
*/
public function setSelectedCurrencyCode($selectedCurrencyCode)
{
$this->selectedCurrencyCode = $selectedCurrencyCode;
return $this;
}
/**
* Get selectedCurrencyCode
*
* @return string
*/
public function getSelectedCurrencyCode()
{
return $this->selectedCurrencyCode;
}
/**
* Set newsletter
*
* @param boolean $newsletter
*
* @return User
*/
public function setNewsletter($newsletter)
{
$this->newsletter = $newsletter;
return $this;
}
/**
* Get newsletter
*
* @return boolean
*/
public function getNewsletter()
{
return $this->newsletter;
}
/**
* Set dealerPrincipal
*
* @param \App\AppBundle\Entity\User $dealerPrincipal
*
* @return User
*/
public function setDealerPrincipal(\App\AppBundle\Entity\User $dealerPrincipal = null)
{
$this->dealerPrincipal = $dealerPrincipal;
return $this;
}
/**
* Get dealerPrincipal
*
* @return \App\AppBundle\Entity\User
*/
public function getDealerPrincipal()
{
return $this->dealerPrincipal;
}
/**
* Add warehouse
*
* @param \App\AppBundle\Entity\Warehouse $warehouse
*
* @return User
*/
public function addWarehouse(\App\AppBundle\Entity\Warehouse $warehouse)
{
$this->warehouses[] = $warehouse;
return $this;
}
/**
* Remove warehouse
*
* @param \App\AppBundle\Entity\Warehouse $warehouse
*/
public function removeWarehouse(\App\AppBundle\Entity\Warehouse $warehouse)
{
$this->warehouses->removeElement($warehouse);
}
/**
* Get warehouses
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getWarehouses()
{
return $this->warehouses;
}
/**
* Set selectedCountry
*
* @param \App\AppBundle\Entity\Country $selectedCountry
*
* @return User
*/
public function setSelectedCountry(\App\AppBundle\Entity\Country $selectedCountry = null)
{
$this->selectedCountry = $selectedCountry;
return $this;
}
/**
* Get selectedCountry
*
* @return \App\AppBundle\Entity\Country
*/
public function getSelectedCountry()
{
return $this->selectedCountry;
}
/**
* Set selectedMacroDealer
*
* @param \App\AppBundle\Entity\MacroDealer $selectedMacroDealer
*
* @return User
*/
public function setSelectedMacroDealer(\App\AppBundle\Entity\MacroDealer $selectedMacroDealer = null)
{
$this->selectedMacroDealer = $selectedMacroDealer;
return $this;
}
/**
* Get selectedMacroDealer
*
* @return \App\AppBundle\Entity\MacroDealer
*/
public function getSelectedMacroDealer()
{
return $this->selectedMacroDealer;
}
/**
* Set selectedWarehouses
*
* @param \App\AppBundle\Entity\Warehouse $selectedWarehouses
*
* @return User
*/
public function setSelectedWarehouses(\App\AppBundle\Entity\Warehouse $selectedWarehouses = null)
{
$this->selectedWarehouses = $selectedWarehouses;
return $this;
}
/**
* Get selectedWarehouses
*
* @return \App\AppBundle\Entity\Warehouse
*/
public function getSelectedWarehouses()
{
return $this->selectedWarehouses;
}
/**
* Add log
*
* @param Log $log
*
* @return User
*/
public function addLog(Log $log)
{
$this->logs[] = $log;
return $this;
}
/**
* Remove log
*
* @param Log $log
*/
public function removeLog(Log $log)
{
$this->logs->removeElement($log);
}
/**
* Get logs
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getLogs()
{
return $this->logs;
}
/**
* Add panel
*
* @param \Coolshop\CoolDashboardBundle\Entity\CdbPanel $panel
*
* @return User
*/
public function addPanel(\Coolshop\CoolDashboardBundle\Entity\CdbPanel $panel)
{
$this->panels[] = $panel;
return $this;
}
/**
* Remove panel
*
* @param \Coolshop\CoolDashboardBundle\Entity\CdbPanel $panel
*/
public function removePanel(\Coolshop\CoolDashboardBundle\Entity\CdbPanel $panel)
{
$this->panels->removeElement($panel);
}
/**
* Get panels
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPanels()
{
return $this->panels;
}
/**
* Set selectedLocale
*
* @param string $selectedLocale
*
* @return User
*/
public function setSelectedLocale($selectedLocale)
{
$this->selectedLocale = $selectedLocale;
return $this;
}
/**
* Get selectedLocale
*
* @return string
*/
public function getSelectedLocale()
{
return $this->selectedLocale;
}
/**
* Add loginLog
*
* @param \App\AppBundle\Entity\LoginLog $loginLog
*
* @return User
*/
public function addLoginLog(\App\AppBundle\Entity\LoginLog $loginLog)
{
$this->loginLogs[] = $loginLog;
return $this;
}
/**
* Remove loginLog
*
* @param \App\AppBundle\Entity\LoginLog $loginLog
*/
public function removeLoginLog(\App\AppBundle\Entity\LoginLog $loginLog)
{
$this->loginLogs->removeElement($loginLog);
}
/**
* Get loginLogs
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getLoginLogs()
{
return $this->loginLogs;
}
/**
* Set selectedMacroDealerGroup
*
* @param integer $selectedMacroDealerGroup
*
* @return User
*/
public function setSelectedMacroDealerGroup($selectedMacroDealerGroup)
{
$this->selectedMacroDealerGroup = $selectedMacroDealerGroup;
return $this;
}
/**
* Get selectedMacroDealerGroup
*
* @return integer
*/
public function getSelectedMacroDealerGroup()
{
return $this->selectedMacroDealerGroup;
}
/**
* @return Dataset[]
*/
public function getDatasets()
{
return $this->datasets;
}
/**
* @param mixed $datasets
*/
public function setDatasets($datasets)
{
$this->datasets = $datasets;
return $this;
}
/**
* @return mixed
*/
public function getConfigurations()
{
return $this->configurations;
}
/**
* @param mixed $configurations
*/
public function setConfigurations($configurations)
{
$this->configurations = $configurations;
return $this;
}
/**
* @return bool
*/
public function isActiveAdvancedAnalytics()
{
return $this->activeAdvancedAnalytics;
}
/**
* @param bool $activeAdvancedAnalytics
*/
public function setActiveAdvancedAnalytics($activeAdvancedAnalytics)
{
$this->activeAdvancedAnalytics = $activeAdvancedAnalytics;
return $this;
}
/**
* @return bool
*/
public function isEnablePredefinedAnalysisCreation()
{
return $this->enablePredefinedAnalysisCreation;
}
/**
* @param bool $enablePredefinedAnalysisCreation
*/
public function setEnablePredefinedAnalysisCreation($enablePredefinedAnalysisCreation)
{
$this->enablePredefinedAnalysisCreation = $enablePredefinedAnalysisCreation;
return $this;
}
/**
* @return bool
*/
public function isEnableSellout()
{
return $this->enableSellout;
}
/**
* @param bool $enableSellout
*/
public function setEnableSellout($enableSellout)
{
$this->enableSellout = $enableSellout;
return $this;
}
/**
* @return bool
*/
public function isEnablePrim()
{
return $this->enablePrim;
}
/**
* @param bool $enablePrim
*/
public function setEnablePrim($enablePrim)
{
$this->enablePrim = $enablePrim;
return $this;
}
/**
* @return bool
*/
public function isEnableUserEdit()
{
return $this->enableUserEdit;
}
/**
* @param bool $enableUserEdit
*/
public function setEnableUserEdit($enableUserEdit)
{
$this->enableUserEdit = $enableUserEdit;
return $this;
}
/**
* @return mixed
*/
public function getMacroDealers()
{
return $this->macroDealers;
}
/**
* @param mixed $macroDealers
*/
public function setMacroDealers($macroDealers)
{
$this->macroDealers = $macroDealers;
}
/**
* @return mixed
*/
public function getCountries()
{
return $this->countries;
}
/**
* @param mixed $countries
*/
public function setCountries($countries)
{
$this->countries = $countries;
}
public function getJSONEncode() {
return json_encode(get_object_vars($this));
}
/**
* Get the value of switchToOld
*/
public function getSwitchToOld()
{
return $this->switchToOld;
}
/**
* Set the value of switchToOld
*
* @return self
*/
public function setSwitchToOld($switchToOld)
{
$this->switchToOld = $switchToOld;
return $this;
}
/** @return string */
public function getSelectedBrands()
{
return $this->selectedBrands;
}
/**
* @param mixed $selectedBrands
* @return void
*/
public function setSelectedBrands($selectedBrands)
{
$this->selectedBrands = $selectedBrands;
}
/**
* Get the value of accessToOld
*
* @return boolean
*/
public function getAccessToOld()
{
return $this->accessToOld;
}
/**
* Set the value of accessToOld
*
* @param boolean $accessToOld
*
* @return self
*/
public function setAccessToOld( $accessToOld)
{
$this->accessToOld = $accessToOld;
return $this;
}
/**
* Get the value of accessToNew
*
* @return boolean
*/
public function getAccessToNew()
{
return $this->accessToNew;
}
/**
* Set the value of accessToNew
*
* @param boolean $accessToNew
*
* @return self
*/
public function setAccessToNew( $accessToNew)
{
$this->accessToNew = $accessToNew;
return $this;
}
/**
* Get the value of market
*/
public function getMarket()
{
return $this->market;
}
/**
* Set the value of market
*
* @return self
*/
public function setMarket($market)
{
$this->market = $market;
return $this;
}
/**
* Get the value of dealerGroup
*/
public function getDealerGroup()
{
return $this->dealerGroup;
}
/**
* Set the value of dealerGroup
*
* @return self
*/
public function setDealerGroup($dealerGroup)
{
$this->dealerGroup = $dealerGroup;
return $this;
}
/**
* Get the value of dealership
*/
public function getDealership()
{
return $this->dealership;
}
/**
* Set the value of dealership
*
* @return self
*/
public function setDealership($dealership)
{
$this->dealership = $dealership;
return $this;
}
public function isEditMode()
{
return $this->isEditMode;
}
public function setIsEditMode($editMode)
{
return $this->isEditMode = $editMode;
}
/**
* Get the value of enableDashboard
*
* @return boolean
*/
public function getEnableDashboard()
{
return $this->enableDashboard;
}
/**
* Set the value of enableDashboard
*
* @param boolean $enableDashboard
*
* @return self
*/
public function setEnableDashboard($enableDashboard)
{
$this->enableDashboard = $enableDashboard;
return $this;
}
/**
* Get the value of enableSellIn
*
* @return boolean
*/
public function getEnableSellIn()
{
return $this->enableSellIn;
}
/**
* Set the value of enableSellIn
*
* @param boolean $enableSellIn
*
* @return self
*/
public function setEnableSellIn($enableSellIn)
{
$this->enableSellIn = $enableSellIn;
return $this;
}
/**
* Get the value of enableAdvancedAnalytics
*
* @return boolean
*/
public function getEnableAdvancedAnalytics()
{
return $this->enableAdvancedAnalytics;
}
/**
* Set the value of enableAdvancedAnalytics
*
* @param boolean $enableAdvancedAnalytics
*
* @return self
*/
public function setEnableAdvancedAnalytics($enableAdvancedAnalytics)
{
$this->enableAdvancedAnalytics = $enableAdvancedAnalytics;
return $this;
}
/**
* Get the value of enableStockAndLogistics
*
* @return boolean
*/
public function getEnableStockAndLogistics()
{
return $this->enableStockAndLogistics;
}
/**
* Set the value of enableStockAndLogistics
*
* @param boolean $enableStockAndLogistics
*
* @return self
*/
public function setEnableStockAndLogistics($enableStockAndLogistics)
{
$this->enableStockAndLogistics = $enableStockAndLogistics;
return $this;
}
/**
* Get the value of enableTakeRate
*
* @return boolean
*/
public function getEnableTakeRate()
{
return $this->enableTakeRate;
}
/**
* Set the value of enableTakeRate
*
* @param boolean $enableTakeRate
*
* @return self
*/
public function setEnableTakeRate($enableTakeRate)
{
$this->enableTakeRate = $enableTakeRate;
return $this;
}
public function getEnableLabelBulkEdit() : bool {
return $this->enableLabelBulkEdit;
}
public function setEnableLabelBulkEdit(bool $enableLabelBulkEdit) : User {
$this->enableLabelBulkEdit = $enableLabelBulkEdit;
return $this;
}
private function isMenuEnabled($id)
{
switch ($id) {
case "new_dashboard":
return $this->getEnableDashboard();
case "new_sellin":
return $this->getEnableSellIn();
case "new_sellout":
return $this->isEnableSellout();
case "new_advance_analytics":
return $this->getEnableAdvancedAnalytics();
case "stock_and_logistics":
return $this->getEnableStockAndLogistics();
case "take_rate_activation_rate":
return $this->getEnableTakeRate();
default:
return false;
}
return false;
}
public function setDefaultUrl($menu) {
$oldMenu = array_filter($menu, function($value) {
return $value['is_old_menu'];
});
$newMenu = array_filter($menu, function($value) {
return !$value['is_old_menu'];
});
if ($this->getSwitchToOld()) {
$defaultMenuVoice = reset($oldMenu);
} else {
$defaultMenuVoice = null;
foreach ($newMenu as $menu) {
if($this->isMenuEnabled($menu["id"])) {
$defaultMenuVoice = $menu;
break;
}
}
}
if(isset($defaultMenuVoice) && isset($defaultMenuVoice['children'])) {
$baseUrl = $this->getSwitchToOld() ? '/dashboard/' : '/dashboard/details/iframe/';
$firstChildren = reset($defaultMenuVoice['children']);
$url = $baseUrl .
$firstChildren['params']['type'] .
'?menuIndex=' . $firstChildren['menu_index'] .
'&submenuIndex=' . $firstChildren['submenu_index'] .
'&parentType=' . $firstChildren['params']['parentType']
;
} else {
throw new AccessDeniedHttpException("User has no visible content");
}
$this->defaultUrl = $url;
}
public function getDefaultUrl() {
return $this->defaultUrl;
}
}