src/AppBundle/Entity/User.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\AppBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\ORM\Mapping\JoinColumn;
  6. use Doctrine\ORM\Mapping\JoinTable;
  7. use Knp\DoctrineBehaviors\Model as ORMBehaviors;
  8. use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. /**
  11. * User
  12. *
  13. * @ORM\Table(name="csps_user")
  14. * @ORM\Entity(repositoryClass="App\AppBundle\Repository\UserRepository")
  15. */
  16. class User implements UserInterface, \Serializable
  17. {
  18. //see role_hierarchy in security.yml to read show's rules
  19. /*******/
  20. /* MIB */
  21. /*******/
  22. /* IS INTERNAL */
  23. const ROLE_MIB_CUSTOMER_CARE = 'ROLE_MIB_CUSTOMER_CARE';
  24. const ROLE_DEALER_ADMIN = 'ROLE_DEALER_ADMIN';
  25. //const ROLE_PSM = 'ROLE_PSM';
  26. //const ROLE_INTERNAL = 'ROLE_INTERNAL';
  27. const ROLE_MARKET_USER = 'ROLE_MARKET_USER';
  28. const ROLE_MIB_CENTRAL_USER = 'ROLE_MIB_CENTRAL_USER';
  29. const ROLE_MIB_PSD = 'ROLE_MIB_PSD';
  30. const ROLE_PSD = 'ROLE_PSD';
  31. const ROLE_KAM = 'ROLE_KAM';
  32. /* ADMIN */
  33. const ROLE_MIB_ADMIN = 'ROLE_MIB_ADMIN';
  34. const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';
  35. /* IS DEALER */
  36. //const ROLE_DEALER = 'ROLE_DEALER';
  37. const ROLE_DEALER_DSM = 'ROLE_DEALER_DSM';
  38. //const ROLE_DP = 'ROLE_DP';
  39. //const ROLE_DOP = 'ROLE_DOP';
  40. const ROLE_WORKSHOP_MANAGER = 'ROLE_WORKSHOP_MANAGER';
  41. const ROLE_PARTS_MANAGER = 'ROLE_PARTS_MANAGER';
  42. const ROLE_GENERAL_MANAGER = 'ROLE_GENERAL_MANAGER';
  43. const ROLE_PARTS_COUNTER = 'ROLE_PARTS_COUNTER';
  44. const ROLE_SERVICE_ADVISOR = 'ROLE_SERVICE_ADVISOR';
  45. /********/
  46. /* ISOD */
  47. /********/
  48. /* IS INTERNAL */
  49. const ROLE_INTERNAL = 'ROLE_INTERNAL';
  50. const ROLE_PSM = 'ROLE_PSM';
  51. /* ADMIN */
  52. const ROLE_ADMIN = 'ROLE_ADMIN';
  53. /* IS DEALER */
  54. const ROLE_DP = 'ROLE_DP';
  55. const ROLE_DEALER = 'ROLE_DEALER';
  56. const ROLE_DOP = 'ROLE_DOP';
  57. /* SPECIAL ROLES */
  58. const ROLE_IS_INTERNAL = 'ROLE_IS_INTERNAL';
  59. const ROLE_IS_DEALER = 'ROLE_IS_DEALER';
  60. const DOP = 1;
  61. const THIRD_PARTS = 2;
  62. const PREDEFINED_ANALYSIS_OWNER_EMAIL = 'emea-next-contact@cnhind.com';
  63. /**
  64. * @ORM\Id
  65. * @ORM\Column(name="id", type="integer")
  66. * @ORM\GeneratedValue(strategy="AUTO")
  67. */
  68. private $id;
  69. /** @ORM\Column(name="firstname", type="string") */
  70. private $firstname;
  71. /** @ORM\Column(name="lastname", type="string") */
  72. private $lastname;
  73. /**
  74. * @var string
  75. *
  76. * @ORM\Column(name="username", type="string", length=28, unique=true)
  77. */
  78. private $username;
  79. /**
  80. * @var string
  81. *
  82. * @ORM\Column(name="password", type="string", length=64, nullable=true)
  83. */
  84. private $password;
  85. /**
  86. * @var string
  87. *
  88. * @ORM\Column(name="email", type="string", length=60, unique=false, nullable=true)
  89. */
  90. private $email;
  91. /**
  92. * @ORM\Column(name="is_active", type="boolean")
  93. */
  94. private $isActive;
  95. /**
  96. * @var array
  97. *
  98. * @ORM\Column(type="simple_array")
  99. */
  100. protected $roles;
  101. /**
  102. * @var array
  103. *
  104. * @ORM\Column(name="roles_myams", type="simple_array")
  105. */
  106. protected $rolesMyAms;
  107. /**
  108. * Many Dealers have one DP
  109. * @ORM\ManyToOne(targetEntity="User", fetch="EAGER")
  110. * @ORM\JoinColumn(name="dealer_id", referencedColumnName="id",onDelete="CASCADE")
  111. *
  112. */
  113. private $dealerPrincipal;
  114. /**
  115. * @ORM\Column(name="last_login", type="datetime", nullable=true)
  116. */
  117. private $lastLogin;
  118. /**
  119. * @ORM\Column(name="last_login_myams", type="datetime", nullable=true)
  120. */
  121. private $lastLoginMyAms;
  122. /**
  123. * @ORM\Column(name="number_of_logins", type="integer")
  124. */
  125. private $numberOfLogins = 0;
  126. /**
  127. * @ORM\Column(name="number_of_logins_myams", type="integer")
  128. */
  129. private $numberOfLoginsMyAms = 0;
  130. /**
  131. * @ORM\ManyToMany(targetEntity="App\AppBundle\Entity\MacroDealer")
  132. * @ORM\JoinTable(name="user_macrodealer",
  133. * joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id",onDelete="CASCADE")},
  134. * inverseJoinColumns={@ORM\JoinColumn(name="macrodealer_id", referencedColumnName="id")}
  135. * )
  136. */
  137. private $macroDealers;
  138. /**
  139. * Many Users have One Warehouse.
  140. * @ORM\ManyToMany(targetEntity="App\AppBundle\Entity\Warehouse")
  141. * @ORM\JoinTable(name="user_warehouse",
  142. * joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id",onDelete="CASCADE")},
  143. * inverseJoinColumns={@ORM\JoinColumn(name="warehouse_id", referencedColumnName="id")}
  144. * )
  145. * @ORM\OrderBy({"whId"="ASC"})
  146. */
  147. private $warehouses;
  148. /**
  149. * Many Users have Many Countries.
  150. * @ORM\ManyToMany(targetEntity="App\AppBundle\Entity\Country")
  151. * @ORM\JoinTable(name="user_country",
  152. * joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id",onDelete="CASCADE")},
  153. * inverseJoinColumns={@ORM\JoinColumn(name="country_id", referencedColumnName="id")}
  154. * )
  155. *
  156. */
  157. private $countries;
  158. /**
  159. * Many users have one or null selectedCountry
  160. * @ORM\ManyToOne(targetEntity="App\AppBundle\Entity\Country")
  161. * @ORM\JoinColumn(name="selected_country", referencedColumnName="id",onDelete="CASCADE")
  162. */
  163. private $selectedCountry;
  164. /**
  165. * Many users have one or null selectedMacroDealer
  166. * @ORM\ManyToOne(targetEntity="App\AppBundle\Entity\MacroDealer")
  167. * @ORM\JoinColumn(name="selected_macro_dealer", referencedColumnName="id",onDelete="CASCADE")
  168. */
  169. private $selectedMacroDealer;
  170. /**
  171. * Many users have one or null selectedWarehouse
  172. * @ORM\ManyToOne(targetEntity="App\AppBundle\Entity\Warehouse")
  173. * @ORM\JoinColumn(name="selected_warehouse", referencedColumnName="id",onDelete="CASCADE")
  174. */
  175. private $selectedWarehouses;
  176. /**
  177. * @var string
  178. *
  179. * @ORM\Column(name="selected_currency_code", type="string", length=7, nullable=true)
  180. */
  181. private $selectedCurrencyCode;
  182. /**
  183. * @var int
  184. *
  185. * @ORM\Column(name="selected_macro_dealer_group", type="integer",nullable=true)
  186. */
  187. private $selectedMacroDealerGroup;
  188. /**
  189. * @var string
  190. *
  191. * @ORM\Column(name="selected_locale", type="string", length=7, nullable=true)
  192. */
  193. private $selectedLocale;
  194. /** @ORM\Column(name="newsletter", type="boolean") */
  195. private $newsletter;
  196. /**
  197. * @var boolean
  198. * @ORM\Column(name="switch_to_old", type="boolean", options={"default":0})
  199. */
  200. private $switchToOld = 0;
  201. /**
  202. * One User have many Log
  203. * @ORM\OneToMany(targetEntity="App\AppBundle\Entity\Log", mappedBy="user",cascade={"REMOVE"})
  204. */
  205. private $logs;
  206. /**
  207. * One User have Many login logs.
  208. * @ORM\OneToMany(targetEntity="App\AppBundle\Entity\LoginLog", mappedBy="user",cascade={"REMOVE"})
  209. */
  210. private $loginLogs;
  211. /**
  212. * Many Users have Many Panels.
  213. * @ORM\ManyToMany(targetEntity="Coolshop\CoolDashboardBundle\Entity\CdbPanel")
  214. * @ORM\JoinTable(name="user_cdb_panel",
  215. * joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id",onDelete="CASCADE")},
  216. * inverseJoinColumns={@ORM\JoinColumn(name="cdb_panel_id", referencedColumnName="id")}
  217. * )
  218. */
  219. private $panels;
  220. /**
  221. * Many Users have Many Datasets.
  222. * @ORM\ManyToMany(targetEntity="App\AppBundle\Entity\Dataset")
  223. * @ORM\JoinTable(name="user_dataset",
  224. * joinColumns={@JoinColumn(name="User_id", referencedColumnName="id",onDelete="CASCADE")},
  225. * inverseJoinColumns={@JoinColumn(name="dataset_id", referencedColumnName="id")}
  226. * )
  227. */
  228. private $datasets;
  229. /**
  230. * One User have Many configurations.
  231. * @ORM\OneToMany(targetEntity="App\AppBundle\Entity\Configuration", mappedBy="user",cascade={"REMOVE"})
  232. */
  233. private $configurations;
  234. /**
  235. * @var boolean
  236. * @ORM\Column(name="active_advanced_analytics", type="boolean", options={"default":0})
  237. */
  238. private $activeAdvancedAnalytics;
  239. /**
  240. * @var boolean
  241. * @ORM\Column(name="enable_predefined_analysis", type="boolean", options={"default":0})
  242. */
  243. private $enablePredefinedAnalysisCreation;
  244. /**
  245. * @var string
  246. *
  247. * @ORM\Column(name="selected_brands", type="string", length=100, unique=false, nullable=true)
  248. */
  249. private $selectedBrands;
  250. /**
  251. * @var boolean
  252. * @ORM\Column(name="access_to_old", type="boolean", options={"default":1})
  253. */
  254. private $accessToOld = true;
  255. /**
  256. * @var boolean
  257. * @ORM\Column(name="access_to_new", type="boolean", options={"default":1})
  258. */
  259. private $accessToNew = true;
  260. /**
  261. * @var boolean
  262. * @ORM\Column(name="enable_sellout", type="boolean", options={"default":1})
  263. */
  264. private $enableSellout = true;
  265. /**
  266. * @var boolean
  267. * @ORM\Column(name="enable_dashboard", type="boolean", options={"default":1})
  268. */
  269. private $enableDashboard = true;
  270. /**
  271. * @var boolean
  272. * @ORM\Column(name="enable_sellin", type="boolean", options={"default":1})
  273. */
  274. private $enableSellIn = true;
  275. /**
  276. * @var boolean
  277. * @ORM\Column(name="enable_advanced_analytics", type="boolean", options={"default":1})
  278. */
  279. private $enableAdvancedAnalytics = true;
  280. /**
  281. * @var boolean
  282. * @ORM\Column(name="enable_stock_and_logistics", type="boolean", options={"default":1})
  283. */
  284. private $enableStockAndLogistics = true;
  285. /**
  286. * @var boolean
  287. * @ORM\Column(name="enable_take_rate", type="boolean", options={"default":1})
  288. */
  289. private $enableTakeRate = true;
  290. /**
  291. * @var boolean
  292. * @ORM\Column(name="enable_prim", type="boolean", options={"default":0})
  293. */
  294. private $enablePrim = false;
  295. /**
  296. * @var boolean
  297. * @ORM\Column(name="enable_user_edit", type="boolean", options={"default":0})
  298. */
  299. private $enableUserEdit = false;
  300. /**
  301. * @var boolean
  302. * @ORM\Column(name="enable_label_bulk_edit", type="boolean", options={"default":0})
  303. */
  304. private $enableLabelBulkEdit = false;
  305. // Just for edit profile table
  306. private $market ;
  307. private $dealerGroup;
  308. private $dealership;
  309. private $isEditMode;
  310. // Just for menus
  311. private $defaultUrl = null;
  312. public function getRoles()
  313. {
  314. return $this->switchToOld ? $this->roles : $this->rolesMyAms;
  315. }
  316. public function getPrettyRole(){
  317. return $this->roles[0];
  318. }
  319. public function getRolesIsod()
  320. {
  321. return $this->roles;
  322. }
  323. public function getRolesMyAms()
  324. {
  325. return $this->rolesMyAms;
  326. }
  327. public function getPrettyMyAmsRole(){
  328. return $this->rolesMyAms[0];
  329. }
  330. public function eraseCredentials()
  331. {
  332. }
  333. /** @see \Serializable::serialize() */
  334. public function serialize()
  335. {
  336. return serialize(array(
  337. $this->id,
  338. $this->username,
  339. $this->password,
  340. $this->isActive
  341. ));
  342. }
  343. /** @see \Serializable::unserialize()
  344. * @param string $serialized
  345. */
  346. public function unserialize($serialized)
  347. {
  348. list (
  349. $this->id,
  350. $this->username,
  351. $this->password,
  352. $this->isActive
  353. ) = unserialize($serialized);
  354. }
  355. public function isAccountNonExpired()
  356. {
  357. return true;
  358. }
  359. public function isAccountNonLocked()
  360. {
  361. return true;
  362. }
  363. public function isCredentialsNonExpired()
  364. {
  365. return true;
  366. }
  367. public function getSalt()
  368. {
  369. return null;
  370. }
  371. public function isEnabled()
  372. {
  373. return $this->isActive;
  374. }
  375. /**
  376. * Set firstname
  377. *
  378. * @param string $firstname
  379. *
  380. * @return User
  381. */
  382. public function setFirstname($firstname)
  383. {
  384. $this->firstname = $firstname;
  385. return $this;
  386. }
  387. /**
  388. * Get firstname
  389. *
  390. * @return string
  391. */
  392. public function getFirstname()
  393. {
  394. return $this->firstname;
  395. }
  396. /**
  397. * Set lastname
  398. *
  399. * @param string $lastname
  400. *
  401. * @return User
  402. */
  403. public function setLastname($lastname)
  404. {
  405. $this->lastname = $lastname;
  406. return $this;
  407. }
  408. /**
  409. * Get lastname
  410. *
  411. * @return string
  412. */
  413. public function getLastname()
  414. {
  415. return $this->lastname;
  416. }
  417. public function getFullUsername() : string
  418. {
  419. $fullname = trim((!empty($this->firstname) ? $this->firstname : "") . " " . (!empty($this->lastname) ? $this->lastname : ""));
  420. return !empty($fullname) ? ($this->username . " - " . $fullname) : $this->username;
  421. }
  422. /**
  423. * Set username
  424. *
  425. * @param string $username
  426. *
  427. * @return User
  428. */
  429. public function setUsername($username)
  430. {
  431. $this->username = $username;
  432. return $this;
  433. }
  434. /**
  435. * Get username
  436. *
  437. * @return string
  438. */
  439. public function getUsername()
  440. {
  441. return $this->username;
  442. }
  443. /**
  444. * Set password
  445. *
  446. * @param string $password
  447. *
  448. * @return User
  449. */
  450. public function setPassword($password)
  451. {
  452. $this->password = $password;
  453. return $this;
  454. }
  455. /**
  456. * Get password
  457. *
  458. * @return string
  459. */
  460. public function getPassword()
  461. {
  462. return $this->password;
  463. }
  464. public function __toString()
  465. {
  466. return $this->getUsername()?:$this->getEmail();
  467. }
  468. /**
  469. * @return bool
  470. */
  471. public function isDealer()
  472. {
  473. return in_array(self::ROLE_DEALER, is_array($this->getRoles()) ? $this->getRoles() : array());
  474. }
  475. /**
  476. * @return bool
  477. */
  478. public function isDealerPrincipal()
  479. {
  480. return in_array(self::ROLE_DP, is_array($this->getRoles()) ? $this->getRoles() : array());
  481. }
  482. public function isDealerDOP()
  483. {
  484. return in_array(self::ROLE_DOP, is_array($this->getRoles()) ? $this->getRoles() : array());
  485. }
  486. public function isDealerPSM()
  487. {
  488. return in_array(self::ROLE_PSM, is_array($this->getRoles()) ? $this->getRoles() : array());
  489. }
  490. public function isWorkshopManager()
  491. {
  492. return in_array(self::ROLE_WORKSHOP_MANAGER, is_array($this->getRoles()) ? $this->getRoles() : array());
  493. }
  494. public function isPartsManager()
  495. {
  496. return in_array(self::ROLE_PARTS_MANAGER, is_array($this->getRoles()) ? $this->getRoles() : array());
  497. }
  498. public function isDealerDms()
  499. {
  500. return in_array(self::ROLE_DEALER_DSM, is_array($this->getRoles()) ? $this->getRoles() : array());
  501. }
  502. public function isGenearlManager()
  503. {
  504. return in_array(self::ROLE_GENERAL_MANAGER, is_array($this->getRoles()) ? $this->getRoles() : array());
  505. }
  506. public function isPartsCounter()
  507. {
  508. return in_array(self::ROLE_PARTS_COUNTER, is_array($this->getRoles()) ? $this->getRoles() : array());
  509. }
  510. public function isServiceAdvisor()
  511. {
  512. return in_array(self::ROLE_SERVICE_ADVISOR, is_array($this->getRoles()) ? $this->getRoles() : array());
  513. }
  514. /**
  515. * @return bool
  516. */
  517. public function hasDealerRole()
  518. {
  519. return $this->isDealer() ||
  520. $this->isDealerPrincipal() ||
  521. $this->isDealerDOP() ||
  522. $this->isDealerPSM() ||
  523. $this->isWorkshopManager() ||
  524. $this->isPartsManager() ||
  525. $this->isDealerDms() ||
  526. $this->isGenearlManager() ||
  527. $this->isPartsCounter() ||
  528. $this->isServiceAdvisor();
  529. }
  530. /**
  531. * @return bool
  532. */
  533. public function hasDealerPrincipalRole()
  534. {
  535. return $this->isDealerPrincipal() || $this->isDealerDOP() || $this->isDealerPSM();
  536. }
  537. /**
  538. * @return bool
  539. */
  540. public function isCustomerCare()
  541. {
  542. return in_array(self::ROLE_MIB_CUSTOMER_CARE, is_array($this->getRoles()) ? $this->getRoles() : array());
  543. }
  544. public function isDealerAdmin(){
  545. return in_array(self::ROLE_DEALER_ADMIN, is_array($this->getRoles()) ? $this->getRoles() : array());
  546. }
  547. public function isMarketUser(){
  548. return in_array(self::ROLE_MARKET_USER, is_array($this->getRoles()) ? $this->getRoles() : array());
  549. }
  550. public function isPSD(){
  551. return in_array(self::ROLE_PSD, is_array($this->getRoles()) ? $this->getRoles() : array());
  552. }
  553. public function isKAM(){
  554. return in_array(self::ROLE_KAM, is_array($this->getRoles()) ? $this->getRoles() : array());
  555. }
  556. /**
  557. * @return bool
  558. */
  559. public function isInternal()
  560. {
  561. return in_array(self::ROLE_INTERNAL, is_array($this->getRoles()) ? $this->getRoles() : array());
  562. }
  563. public function hasInternalRole()
  564. {
  565. return $this->isInternal() || $this->isMarketUser() || $this->isPSD() || $this->isKAM();
  566. }
  567. /**
  568. * @return bool
  569. */
  570. public function isAdmin()
  571. {
  572. return in_array(self::ROLE_ADMIN, is_array($this->getRoles()) ? $this->getRoles() : array()) ||
  573. in_array(self::ROLE_SUPER_ADMIN, is_array($this->getRoles()) ? $this->getRoles() : array()) ||
  574. in_array(self::ROLE_MIB_ADMIN, is_array($this->getRoles()) ? $this->getRoles() : array());
  575. }
  576. /* autogenerated */
  577. /**
  578. * Constructor
  579. */
  580. public function __construct()
  581. {
  582. $this->warehouses = new \Doctrine\Common\Collections\ArrayCollection();
  583. $this->logs = new \Doctrine\Common\Collections\ArrayCollection();
  584. $this->panels = new \Doctrine\Common\Collections\ArrayCollection();
  585. $this->loginLogs = new \Doctrine\Common\Collections\ArrayCollection();
  586. //$this->market = new \Doctrine\Common\Collections\ArrayCollection();
  587. //$this->dealerGroup = new \Doctrine\Common\Collections\ArrayCollection();
  588. //$this->dealership = new \Doctrine\Common\Collections\ArrayCollection();
  589. }
  590. /**
  591. * Get id
  592. *
  593. * @return integer
  594. */
  595. public function getId()
  596. {
  597. return $this->id;
  598. }
  599. /**
  600. * Set email
  601. *
  602. * @param string $email
  603. *
  604. * @return User
  605. */
  606. public function setEmail($email)
  607. {
  608. $this->email = $email;
  609. return $this;
  610. }
  611. /**
  612. * Get email
  613. *
  614. * @return string
  615. */
  616. public function getEmail()
  617. {
  618. return $this->email;
  619. }
  620. /**
  621. * Set isActive
  622. *
  623. * @param boolean $isActive
  624. *
  625. * @return User
  626. */
  627. public function setIsActive($isActive)
  628. {
  629. $this->isActive = $isActive;
  630. return $this;
  631. }
  632. /**
  633. * Get isActive
  634. *
  635. * @return boolean
  636. */
  637. public function getIsActive()
  638. {
  639. return $this->isActive;
  640. }
  641. /**
  642. * Set roles
  643. *
  644. * @param array $roles
  645. *
  646. * @return User
  647. */
  648. public function setRoles($roles)
  649. {
  650. $this->roles = $roles;
  651. return $this;
  652. }
  653. /**
  654. * Set rolesMyAms
  655. *
  656. * @param array $rolesMyAms
  657. *
  658. * @return User
  659. */
  660. public function setRolesMyAms($rolesMyAms)
  661. {
  662. $this->rolesMyAms = $rolesMyAms;
  663. return $this;
  664. }
  665. /**
  666. * Set lastLogin
  667. *
  668. * @param \DateTime $lastLogin
  669. *
  670. * @return User
  671. */
  672. public function setLastLogin($lastLogin)
  673. {
  674. $this->lastLogin = $lastLogin;
  675. return $this;
  676. }
  677. /**
  678. * Set lastLoginMyAms
  679. *
  680. * @param \DateTime $lastLoginMyAms
  681. *
  682. * @return User
  683. */
  684. public function setlastLoginMyAms($lastLogin)
  685. {
  686. $this->lastLoginMyAms = $lastLogin;
  687. return $this;
  688. }
  689. /**
  690. * Get lastLogin
  691. *
  692. * @return \DateTime
  693. */
  694. public function getLastLogin()
  695. {
  696. return $this->lastLogin;
  697. }
  698. /**
  699. * Get lastLoginMyAms
  700. *
  701. * @return \DateTime
  702. */
  703. public function getlastLoginMyAms()
  704. {
  705. return $this->lastLoginMyAms;
  706. }
  707. /**
  708. * Set numberOfLogins
  709. *
  710. * @param integer $numberOfLogins
  711. *
  712. * @return User
  713. */
  714. public function setNumberOfLogins($numberOfLogins)
  715. {
  716. $this->numberOfLogins = $numberOfLogins;
  717. return $this;
  718. }
  719. /**
  720. * Get numberOfLogins
  721. *
  722. * @return integer
  723. */
  724. public function getNumberOfLogins()
  725. {
  726. return $this->numberOfLogins;
  727. }
  728. /**
  729. * Set numberOfLoginsMyAms
  730. *
  731. * @param integer $numberOfLoginsMyAms
  732. *
  733. * @return User
  734. */
  735. public function setNumberOfLoginsMyAms($numberOfLoginsMyAms)
  736. {
  737. $this->numberOfLoginsMyAms = $numberOfLoginsMyAms;
  738. return $this;
  739. }
  740. /**
  741. * Get numberOfLoginsMyAms
  742. *
  743. * @return integer
  744. */
  745. public function getNumberOfLoginsMyAms()
  746. {
  747. return $this->numberOfLoginsMyAms;
  748. }
  749. /**
  750. * Set selectedCurrencyCode
  751. *
  752. * @param string $selectedCurrencyCode
  753. *
  754. * @return User
  755. */
  756. public function setSelectedCurrencyCode($selectedCurrencyCode)
  757. {
  758. $this->selectedCurrencyCode = $selectedCurrencyCode;
  759. return $this;
  760. }
  761. /**
  762. * Get selectedCurrencyCode
  763. *
  764. * @return string
  765. */
  766. public function getSelectedCurrencyCode()
  767. {
  768. return $this->selectedCurrencyCode;
  769. }
  770. /**
  771. * Set newsletter
  772. *
  773. * @param boolean $newsletter
  774. *
  775. * @return User
  776. */
  777. public function setNewsletter($newsletter)
  778. {
  779. $this->newsletter = $newsletter;
  780. return $this;
  781. }
  782. /**
  783. * Get newsletter
  784. *
  785. * @return boolean
  786. */
  787. public function getNewsletter()
  788. {
  789. return $this->newsletter;
  790. }
  791. /**
  792. * Set dealerPrincipal
  793. *
  794. * @param \App\AppBundle\Entity\User $dealerPrincipal
  795. *
  796. * @return User
  797. */
  798. public function setDealerPrincipal(\App\AppBundle\Entity\User $dealerPrincipal = null)
  799. {
  800. $this->dealerPrincipal = $dealerPrincipal;
  801. return $this;
  802. }
  803. /**
  804. * Get dealerPrincipal
  805. *
  806. * @return \App\AppBundle\Entity\User
  807. */
  808. public function getDealerPrincipal()
  809. {
  810. return $this->dealerPrincipal;
  811. }
  812. /**
  813. * Add warehouse
  814. *
  815. * @param \App\AppBundle\Entity\Warehouse $warehouse
  816. *
  817. * @return User
  818. */
  819. public function addWarehouse(\App\AppBundle\Entity\Warehouse $warehouse)
  820. {
  821. $this->warehouses[] = $warehouse;
  822. return $this;
  823. }
  824. /**
  825. * Remove warehouse
  826. *
  827. * @param \App\AppBundle\Entity\Warehouse $warehouse
  828. */
  829. public function removeWarehouse(\App\AppBundle\Entity\Warehouse $warehouse)
  830. {
  831. $this->warehouses->removeElement($warehouse);
  832. }
  833. /**
  834. * Get warehouses
  835. *
  836. * @return \Doctrine\Common\Collections\Collection
  837. */
  838. public function getWarehouses()
  839. {
  840. return $this->warehouses;
  841. }
  842. /**
  843. * Set selectedCountry
  844. *
  845. * @param \App\AppBundle\Entity\Country $selectedCountry
  846. *
  847. * @return User
  848. */
  849. public function setSelectedCountry(\App\AppBundle\Entity\Country $selectedCountry = null)
  850. {
  851. $this->selectedCountry = $selectedCountry;
  852. return $this;
  853. }
  854. /**
  855. * Get selectedCountry
  856. *
  857. * @return \App\AppBundle\Entity\Country
  858. */
  859. public function getSelectedCountry()
  860. {
  861. return $this->selectedCountry;
  862. }
  863. /**
  864. * Set selectedMacroDealer
  865. *
  866. * @param \App\AppBundle\Entity\MacroDealer $selectedMacroDealer
  867. *
  868. * @return User
  869. */
  870. public function setSelectedMacroDealer(\App\AppBundle\Entity\MacroDealer $selectedMacroDealer = null)
  871. {
  872. $this->selectedMacroDealer = $selectedMacroDealer;
  873. return $this;
  874. }
  875. /**
  876. * Get selectedMacroDealer
  877. *
  878. * @return \App\AppBundle\Entity\MacroDealer
  879. */
  880. public function getSelectedMacroDealer()
  881. {
  882. return $this->selectedMacroDealer;
  883. }
  884. /**
  885. * Set selectedWarehouses
  886. *
  887. * @param \App\AppBundle\Entity\Warehouse $selectedWarehouses
  888. *
  889. * @return User
  890. */
  891. public function setSelectedWarehouses(\App\AppBundle\Entity\Warehouse $selectedWarehouses = null)
  892. {
  893. $this->selectedWarehouses = $selectedWarehouses;
  894. return $this;
  895. }
  896. /**
  897. * Get selectedWarehouses
  898. *
  899. * @return \App\AppBundle\Entity\Warehouse
  900. */
  901. public function getSelectedWarehouses()
  902. {
  903. return $this->selectedWarehouses;
  904. }
  905. /**
  906. * Add log
  907. *
  908. * @param Log $log
  909. *
  910. * @return User
  911. */
  912. public function addLog(Log $log)
  913. {
  914. $this->logs[] = $log;
  915. return $this;
  916. }
  917. /**
  918. * Remove log
  919. *
  920. * @param Log $log
  921. */
  922. public function removeLog(Log $log)
  923. {
  924. $this->logs->removeElement($log);
  925. }
  926. /**
  927. * Get logs
  928. *
  929. * @return \Doctrine\Common\Collections\Collection
  930. */
  931. public function getLogs()
  932. {
  933. return $this->logs;
  934. }
  935. /**
  936. * Add panel
  937. *
  938. * @param \Coolshop\CoolDashboardBundle\Entity\CdbPanel $panel
  939. *
  940. * @return User
  941. */
  942. public function addPanel(\Coolshop\CoolDashboardBundle\Entity\CdbPanel $panel)
  943. {
  944. $this->panels[] = $panel;
  945. return $this;
  946. }
  947. /**
  948. * Remove panel
  949. *
  950. * @param \Coolshop\CoolDashboardBundle\Entity\CdbPanel $panel
  951. */
  952. public function removePanel(\Coolshop\CoolDashboardBundle\Entity\CdbPanel $panel)
  953. {
  954. $this->panels->removeElement($panel);
  955. }
  956. /**
  957. * Get panels
  958. *
  959. * @return \Doctrine\Common\Collections\Collection
  960. */
  961. public function getPanels()
  962. {
  963. return $this->panels;
  964. }
  965. /**
  966. * Set selectedLocale
  967. *
  968. * @param string $selectedLocale
  969. *
  970. * @return User
  971. */
  972. public function setSelectedLocale($selectedLocale)
  973. {
  974. $this->selectedLocale = $selectedLocale;
  975. return $this;
  976. }
  977. /**
  978. * Get selectedLocale
  979. *
  980. * @return string
  981. */
  982. public function getSelectedLocale()
  983. {
  984. return $this->selectedLocale;
  985. }
  986. /**
  987. * Add loginLog
  988. *
  989. * @param \App\AppBundle\Entity\LoginLog $loginLog
  990. *
  991. * @return User
  992. */
  993. public function addLoginLog(\App\AppBundle\Entity\LoginLog $loginLog)
  994. {
  995. $this->loginLogs[] = $loginLog;
  996. return $this;
  997. }
  998. /**
  999. * Remove loginLog
  1000. *
  1001. * @param \App\AppBundle\Entity\LoginLog $loginLog
  1002. */
  1003. public function removeLoginLog(\App\AppBundle\Entity\LoginLog $loginLog)
  1004. {
  1005. $this->loginLogs->removeElement($loginLog);
  1006. }
  1007. /**
  1008. * Get loginLogs
  1009. *
  1010. * @return \Doctrine\Common\Collections\Collection
  1011. */
  1012. public function getLoginLogs()
  1013. {
  1014. return $this->loginLogs;
  1015. }
  1016. /**
  1017. * Set selectedMacroDealerGroup
  1018. *
  1019. * @param integer $selectedMacroDealerGroup
  1020. *
  1021. * @return User
  1022. */
  1023. public function setSelectedMacroDealerGroup($selectedMacroDealerGroup)
  1024. {
  1025. $this->selectedMacroDealerGroup = $selectedMacroDealerGroup;
  1026. return $this;
  1027. }
  1028. /**
  1029. * Get selectedMacroDealerGroup
  1030. *
  1031. * @return integer
  1032. */
  1033. public function getSelectedMacroDealerGroup()
  1034. {
  1035. return $this->selectedMacroDealerGroup;
  1036. }
  1037. /**
  1038. * @return Dataset[]
  1039. */
  1040. public function getDatasets()
  1041. {
  1042. return $this->datasets;
  1043. }
  1044. /**
  1045. * @param mixed $datasets
  1046. */
  1047. public function setDatasets($datasets)
  1048. {
  1049. $this->datasets = $datasets;
  1050. return $this;
  1051. }
  1052. /**
  1053. * @return mixed
  1054. */
  1055. public function getConfigurations()
  1056. {
  1057. return $this->configurations;
  1058. }
  1059. /**
  1060. * @param mixed $configurations
  1061. */
  1062. public function setConfigurations($configurations)
  1063. {
  1064. $this->configurations = $configurations;
  1065. return $this;
  1066. }
  1067. /**
  1068. * @return bool
  1069. */
  1070. public function isActiveAdvancedAnalytics()
  1071. {
  1072. return $this->activeAdvancedAnalytics;
  1073. }
  1074. /**
  1075. * @param bool $activeAdvancedAnalytics
  1076. */
  1077. public function setActiveAdvancedAnalytics($activeAdvancedAnalytics)
  1078. {
  1079. $this->activeAdvancedAnalytics = $activeAdvancedAnalytics;
  1080. return $this;
  1081. }
  1082. /**
  1083. * @return bool
  1084. */
  1085. public function isEnablePredefinedAnalysisCreation()
  1086. {
  1087. return $this->enablePredefinedAnalysisCreation;
  1088. }
  1089. /**
  1090. * @param bool $enablePredefinedAnalysisCreation
  1091. */
  1092. public function setEnablePredefinedAnalysisCreation($enablePredefinedAnalysisCreation)
  1093. {
  1094. $this->enablePredefinedAnalysisCreation = $enablePredefinedAnalysisCreation;
  1095. return $this;
  1096. }
  1097. /**
  1098. * @return bool
  1099. */
  1100. public function isEnableSellout()
  1101. {
  1102. return $this->enableSellout;
  1103. }
  1104. /**
  1105. * @param bool $enableSellout
  1106. */
  1107. public function setEnableSellout($enableSellout)
  1108. {
  1109. $this->enableSellout = $enableSellout;
  1110. return $this;
  1111. }
  1112. /**
  1113. * @return bool
  1114. */
  1115. public function isEnablePrim()
  1116. {
  1117. return $this->enablePrim;
  1118. }
  1119. /**
  1120. * @param bool $enablePrim
  1121. */
  1122. public function setEnablePrim($enablePrim)
  1123. {
  1124. $this->enablePrim = $enablePrim;
  1125. return $this;
  1126. }
  1127. /**
  1128. * @return bool
  1129. */
  1130. public function isEnableUserEdit()
  1131. {
  1132. return $this->enableUserEdit;
  1133. }
  1134. /**
  1135. * @param bool $enableUserEdit
  1136. */
  1137. public function setEnableUserEdit($enableUserEdit)
  1138. {
  1139. $this->enableUserEdit = $enableUserEdit;
  1140. return $this;
  1141. }
  1142. /**
  1143. * @return mixed
  1144. */
  1145. public function getMacroDealers()
  1146. {
  1147. return $this->macroDealers;
  1148. }
  1149. /**
  1150. * @param mixed $macroDealers
  1151. */
  1152. public function setMacroDealers($macroDealers)
  1153. {
  1154. $this->macroDealers = $macroDealers;
  1155. }
  1156. /**
  1157. * @return mixed
  1158. */
  1159. public function getCountries()
  1160. {
  1161. return $this->countries;
  1162. }
  1163. /**
  1164. * @param mixed $countries
  1165. */
  1166. public function setCountries($countries)
  1167. {
  1168. $this->countries = $countries;
  1169. }
  1170. public function getJSONEncode() {
  1171. return json_encode(get_object_vars($this));
  1172. }
  1173. /**
  1174. * Get the value of switchToOld
  1175. */
  1176. public function getSwitchToOld()
  1177. {
  1178. return $this->switchToOld;
  1179. }
  1180. /**
  1181. * Set the value of switchToOld
  1182. *
  1183. * @return self
  1184. */
  1185. public function setSwitchToOld($switchToOld)
  1186. {
  1187. $this->switchToOld = $switchToOld;
  1188. return $this;
  1189. }
  1190. /** @return string */
  1191. public function getSelectedBrands()
  1192. {
  1193. return $this->selectedBrands;
  1194. }
  1195. /**
  1196. * @param mixed $selectedBrands
  1197. * @return void
  1198. */
  1199. public function setSelectedBrands($selectedBrands)
  1200. {
  1201. $this->selectedBrands = $selectedBrands;
  1202. }
  1203. /**
  1204. * Get the value of accessToOld
  1205. *
  1206. * @return boolean
  1207. */
  1208. public function getAccessToOld()
  1209. {
  1210. return $this->accessToOld;
  1211. }
  1212. /**
  1213. * Set the value of accessToOld
  1214. *
  1215. * @param boolean $accessToOld
  1216. *
  1217. * @return self
  1218. */
  1219. public function setAccessToOld( $accessToOld)
  1220. {
  1221. $this->accessToOld = $accessToOld;
  1222. return $this;
  1223. }
  1224. /**
  1225. * Get the value of accessToNew
  1226. *
  1227. * @return boolean
  1228. */
  1229. public function getAccessToNew()
  1230. {
  1231. return $this->accessToNew;
  1232. }
  1233. /**
  1234. * Set the value of accessToNew
  1235. *
  1236. * @param boolean $accessToNew
  1237. *
  1238. * @return self
  1239. */
  1240. public function setAccessToNew( $accessToNew)
  1241. {
  1242. $this->accessToNew = $accessToNew;
  1243. return $this;
  1244. }
  1245. /**
  1246. * Get the value of market
  1247. */
  1248. public function getMarket()
  1249. {
  1250. return $this->market;
  1251. }
  1252. /**
  1253. * Set the value of market
  1254. *
  1255. * @return self
  1256. */
  1257. public function setMarket($market)
  1258. {
  1259. $this->market = $market;
  1260. return $this;
  1261. }
  1262. /**
  1263. * Get the value of dealerGroup
  1264. */
  1265. public function getDealerGroup()
  1266. {
  1267. return $this->dealerGroup;
  1268. }
  1269. /**
  1270. * Set the value of dealerGroup
  1271. *
  1272. * @return self
  1273. */
  1274. public function setDealerGroup($dealerGroup)
  1275. {
  1276. $this->dealerGroup = $dealerGroup;
  1277. return $this;
  1278. }
  1279. /**
  1280. * Get the value of dealership
  1281. */
  1282. public function getDealership()
  1283. {
  1284. return $this->dealership;
  1285. }
  1286. /**
  1287. * Set the value of dealership
  1288. *
  1289. * @return self
  1290. */
  1291. public function setDealership($dealership)
  1292. {
  1293. $this->dealership = $dealership;
  1294. return $this;
  1295. }
  1296. public function isEditMode()
  1297. {
  1298. return $this->isEditMode;
  1299. }
  1300. public function setIsEditMode($editMode)
  1301. {
  1302. return $this->isEditMode = $editMode;
  1303. }
  1304. /**
  1305. * Get the value of enableDashboard
  1306. *
  1307. * @return boolean
  1308. */
  1309. public function getEnableDashboard()
  1310. {
  1311. return $this->enableDashboard;
  1312. }
  1313. /**
  1314. * Set the value of enableDashboard
  1315. *
  1316. * @param boolean $enableDashboard
  1317. *
  1318. * @return self
  1319. */
  1320. public function setEnableDashboard($enableDashboard)
  1321. {
  1322. $this->enableDashboard = $enableDashboard;
  1323. return $this;
  1324. }
  1325. /**
  1326. * Get the value of enableSellIn
  1327. *
  1328. * @return boolean
  1329. */
  1330. public function getEnableSellIn()
  1331. {
  1332. return $this->enableSellIn;
  1333. }
  1334. /**
  1335. * Set the value of enableSellIn
  1336. *
  1337. * @param boolean $enableSellIn
  1338. *
  1339. * @return self
  1340. */
  1341. public function setEnableSellIn($enableSellIn)
  1342. {
  1343. $this->enableSellIn = $enableSellIn;
  1344. return $this;
  1345. }
  1346. /**
  1347. * Get the value of enableAdvancedAnalytics
  1348. *
  1349. * @return boolean
  1350. */
  1351. public function getEnableAdvancedAnalytics()
  1352. {
  1353. return $this->enableAdvancedAnalytics;
  1354. }
  1355. /**
  1356. * Set the value of enableAdvancedAnalytics
  1357. *
  1358. * @param boolean $enableAdvancedAnalytics
  1359. *
  1360. * @return self
  1361. */
  1362. public function setEnableAdvancedAnalytics($enableAdvancedAnalytics)
  1363. {
  1364. $this->enableAdvancedAnalytics = $enableAdvancedAnalytics;
  1365. return $this;
  1366. }
  1367. /**
  1368. * Get the value of enableStockAndLogistics
  1369. *
  1370. * @return boolean
  1371. */
  1372. public function getEnableStockAndLogistics()
  1373. {
  1374. return $this->enableStockAndLogistics;
  1375. }
  1376. /**
  1377. * Set the value of enableStockAndLogistics
  1378. *
  1379. * @param boolean $enableStockAndLogistics
  1380. *
  1381. * @return self
  1382. */
  1383. public function setEnableStockAndLogistics($enableStockAndLogistics)
  1384. {
  1385. $this->enableStockAndLogistics = $enableStockAndLogistics;
  1386. return $this;
  1387. }
  1388. /**
  1389. * Get the value of enableTakeRate
  1390. *
  1391. * @return boolean
  1392. */
  1393. public function getEnableTakeRate()
  1394. {
  1395. return $this->enableTakeRate;
  1396. }
  1397. /**
  1398. * Set the value of enableTakeRate
  1399. *
  1400. * @param boolean $enableTakeRate
  1401. *
  1402. * @return self
  1403. */
  1404. public function setEnableTakeRate($enableTakeRate)
  1405. {
  1406. $this->enableTakeRate = $enableTakeRate;
  1407. return $this;
  1408. }
  1409. public function getEnableLabelBulkEdit() : bool {
  1410. return $this->enableLabelBulkEdit;
  1411. }
  1412. public function setEnableLabelBulkEdit(bool $enableLabelBulkEdit) : User {
  1413. $this->enableLabelBulkEdit = $enableLabelBulkEdit;
  1414. return $this;
  1415. }
  1416. private function isMenuEnabled($id)
  1417. {
  1418. switch ($id) {
  1419. case "new_dashboard":
  1420. return $this->getEnableDashboard();
  1421. case "new_sellin":
  1422. return $this->getEnableSellIn();
  1423. case "new_sellout":
  1424. return $this->isEnableSellout();
  1425. case "new_advance_analytics":
  1426. return $this->getEnableAdvancedAnalytics();
  1427. case "stock_and_logistics":
  1428. return $this->getEnableStockAndLogistics();
  1429. case "take_rate_activation_rate":
  1430. return $this->getEnableTakeRate();
  1431. default:
  1432. return false;
  1433. }
  1434. return false;
  1435. }
  1436. public function setDefaultUrl($menu) {
  1437. $oldMenu = array_filter($menu, function($value) {
  1438. return $value['is_old_menu'];
  1439. });
  1440. $newMenu = array_filter($menu, function($value) {
  1441. return !$value['is_old_menu'];
  1442. });
  1443. if ($this->getSwitchToOld()) {
  1444. $defaultMenuVoice = reset($oldMenu);
  1445. } else {
  1446. $defaultMenuVoice = null;
  1447. foreach ($newMenu as $menu) {
  1448. if($this->isMenuEnabled($menu["id"])) {
  1449. $defaultMenuVoice = $menu;
  1450. break;
  1451. }
  1452. }
  1453. }
  1454. if(isset($defaultMenuVoice) && isset($defaultMenuVoice['children'])) {
  1455. $baseUrl = $this->getSwitchToOld() ? '/dashboard/' : '/dashboard/details/iframe/';
  1456. $firstChildren = reset($defaultMenuVoice['children']);
  1457. $url = $baseUrl .
  1458. $firstChildren['params']['type'] .
  1459. '?menuIndex=' . $firstChildren['menu_index'] .
  1460. '&submenuIndex=' . $firstChildren['submenu_index'] .
  1461. '&parentType=' . $firstChildren['params']['parentType']
  1462. ;
  1463. } else {
  1464. throw new AccessDeniedHttpException("User has no visible content");
  1465. }
  1466. $this->defaultUrl = $url;
  1467. }
  1468. public function getDefaultUrl() {
  1469. return $this->defaultUrl;
  1470. }
  1471. }