src/Entity/Idempiere/AdUser.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Idempiere;
  3. use App\Repository\Idempiere\AdUserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\PasswordHasher\Hasher\PasswordHasherAwareInterface;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. /**
  11. * @ORM\Entity(repositoryClass=AdUserRepository::class)
  12. * @ORM\Table(name="ad_user")
  13. */
  14. class AdUser implements
  15. UserInterface,
  16. PasswordAuthenticatedUserInterface,
  17. PasswordHasherAwareInterface
  18. {
  19. /**
  20. * @ORM\Id
  21. * @ORM\Column(type="integer")
  22. */
  23. private $ad_user_id;
  24. /**
  25. * @ORM\Column(type="string", length=36)
  26. */
  27. private $ad_user_uu;
  28. /**
  29. * @ORM\Column(type="integer")
  30. */
  31. private $ad_client_id;
  32. /**
  33. * @ORM\Column(type="string", length=1)
  34. */
  35. private $isactive;
  36. /**
  37. * @ORM\Column(type="datetime")
  38. */
  39. private $created;
  40. /**
  41. * @ORM\Column(type="integer")
  42. */
  43. private $createdby;
  44. /**
  45. * @ORM\Column(type="datetime")
  46. */
  47. private $updated;
  48. /**
  49. * @ORM\Column(type="integer")
  50. */
  51. private $updatedby;
  52. /**
  53. * @ORM\Column(type="string", length=255)
  54. */
  55. private $name;
  56. /**
  57. * @ORM\Column(type="string", length=255)
  58. */
  59. private $description;
  60. /**
  61. * @ORM\Column(type="string", length=255)
  62. */
  63. private $password;
  64. /**
  65. * @ORM\Column(type="string", length=255)
  66. */
  67. private $email;
  68. /**
  69. * @ORM\Column(type="string", length=255, nullable=true)
  70. */
  71. private $phone;
  72. /**
  73. * @ORM\Column(type="datetime", nullable=true)
  74. */
  75. private $birthday;
  76. /**
  77. * @ORM\Column(type="string", length=255)
  78. */
  79. private $salt;
  80. /**
  81. * @ORM\Column(type="string", length=1)
  82. */
  83. private $islocked;
  84. /**
  85. * @ORM\Column(type="datetime", nullable=true)
  86. */
  87. private $dateaccountlocked;
  88. /**
  89. * @ORM\Column(type="integer")
  90. */
  91. private $failedlogincount;
  92. /**
  93. * @ORM\Column(type="datetime", nullable=true)
  94. */
  95. private $datepasswordchanged;
  96. /**
  97. * @ORM\Column(type="datetime", nullable=true)
  98. */
  99. private $datelastlogin;
  100. /**
  101. * @ORM\Column(type="string", length=1)
  102. */
  103. private $isexpired;
  104. /**
  105. * @ORM\Column(type="string", length=255, nullable=true)
  106. */
  107. private $securityquestion;
  108. /**
  109. * @ORM\Column(type="string", length=255, nullable=true)
  110. */
  111. private $answer;
  112. /**
  113. * @ORM\ManyToOne(targetEntity=CBpartner::class)
  114. * @ORM\JoinColumn(referencedColumnName="c_bpartner_id", nullable=false)
  115. */
  116. private $c_bpartner;
  117. /**
  118. * @ORM\Column(type="integer")
  119. */
  120. private $c_bpartner_id;
  121. /**
  122. * @ORM\ManyToOne(targetEntity=CBpartnerLocation::class)
  123. * @ORM\JoinColumn(referencedColumnName="c_bpartner_location_id", nullable=false)
  124. */
  125. private $c_bpartner_location;
  126. /**
  127. * @ORM\Column(type="integer", nullable=true)
  128. */
  129. private $c_bpartner_location_id;
  130. /**
  131. * @ORM\OneToMany(targetEntity=AdUserRoles::class, mappedBy="ad_user")
  132. */
  133. private $ad_user_roles;
  134. /**
  135. * @ORM\OneToMany(targetEntity=AdUserOrgaccess::class, mappedBy="ad_user")
  136. */
  137. private $ad_user_orgaccesses;
  138. /**
  139. * @ORM\ManyToOne(targetEntity=CActivity::class, inversedBy="ad_users")
  140. * @ORM\JoinColumn(referencedColumnName="c_activity_id", nullable=false)
  141. */
  142. private $c_activity;
  143. /**
  144. * @ORM\Column(type="integer", nullable=true)
  145. */
  146. private $c_activity_id;
  147. /**
  148. * @ORM\Column(type="integer", nullable=true)
  149. */
  150. private $salesrep_id;
  151. /**
  152. * @ORM\OneToOne(targetEntity=SmSalesRep::class, mappedBy="ad_user")
  153. */
  154. private $salesRep;
  155. public function __construct()
  156. {
  157. $this->ad_user_roles = new ArrayCollection();
  158. $this->ad_user_orgaccesses = new ArrayCollection();
  159. }
  160. public function getPasswordHasherName(): ?string
  161. {
  162. return 'idempiere';
  163. }
  164. public function getId(): int
  165. {
  166. return $this->getAdUserId();
  167. }
  168. public function getAdUserId(): ?int
  169. {
  170. return $this->ad_user_id;
  171. }
  172. public function setAdUserId(int $ad_user_id): self
  173. {
  174. $this->ad_user_id = $ad_user_id;
  175. return $this;
  176. }
  177. public function getAdUserUu(): ?string
  178. {
  179. return $this->ad_user_uu;
  180. }
  181. public function setAdUserUu(string $ad_user_uu): self
  182. {
  183. $this->ad_user_uu = $ad_user_uu;
  184. return $this;
  185. }
  186. public function getAdClientId(): ?int
  187. {
  188. return $this->ad_client_id;
  189. }
  190. public function setAdClientId(int $ad_client_id): self
  191. {
  192. $this->ad_client_id = $ad_client_id;
  193. return $this;
  194. }
  195. public function isActive(): ?bool
  196. {
  197. return $this->getIsactive() === "Y";
  198. }
  199. public function getIsactive(): ?string
  200. {
  201. return $this->isactive;
  202. }
  203. public function setIsactive(string $isactive): self
  204. {
  205. $this->isactive = $isactive;
  206. return $this;
  207. }
  208. public function setActive(bool $active): self
  209. {
  210. $this->setIsactive($active ? "Y" : "N");
  211. return $this;
  212. }
  213. public function getCreated(): ?\DateTimeInterface
  214. {
  215. return $this->created;
  216. }
  217. public function setCreated(\DateTimeInterface $created): self
  218. {
  219. $this->created = $created;
  220. return $this;
  221. }
  222. public function getCreatedby(): ?int
  223. {
  224. return $this->createdby;
  225. }
  226. public function setCreatedby(int $createdby): self
  227. {
  228. $this->createdby = $createdby;
  229. return $this;
  230. }
  231. public function getUpdated(): ?\DateTimeInterface
  232. {
  233. return $this->updated;
  234. }
  235. public function setUpdated(\DateTimeInterface $updated): self
  236. {
  237. $this->updated = $updated;
  238. return $this;
  239. }
  240. public function getUpdatedby(): ?int
  241. {
  242. return $this->updatedby;
  243. }
  244. public function setUpdatedby(int $updatedby): self
  245. {
  246. $this->updatedby = $updatedby;
  247. return $this;
  248. }
  249. public function getName(): ?string
  250. {
  251. return $this->name;
  252. }
  253. public function setName(string $name): self
  254. {
  255. $this->name = $name;
  256. return $this;
  257. }
  258. public function getUsername(): ?string
  259. {
  260. return $this->name;
  261. }
  262. /**
  263. * The public representation of the user (e.g a username, an email)
  264. *
  265. * @see UserInterface
  266. */
  267. public function getUserIdentifier(): String
  268. {
  269. return (string) $this->name;
  270. }
  271. public function getDescription(): ?string
  272. {
  273. return $this->description;
  274. }
  275. public function setDescription(string $description): self
  276. {
  277. $this->description = $description;
  278. return $this;
  279. }
  280. /**
  281. * @see PasswordAuthenticatedUserInterface
  282. */
  283. public function getPassword(): ?string
  284. {
  285. return $this->password;
  286. }
  287. public function setPassword(string $password): self
  288. {
  289. $this->password = $password;
  290. return $this;
  291. }
  292. public function getEmail(): ?string
  293. {
  294. return $this->email;
  295. }
  296. public function setEmail(string $email): self
  297. {
  298. $this->email = $email;
  299. return $this;
  300. }
  301. public function getPhone(): ?string
  302. {
  303. return $this->phone;
  304. }
  305. public function setPhone(?string $phone): self
  306. {
  307. $this->phone = $phone;
  308. return $this;
  309. }
  310. public function getBirthday(): ?\DateTimeInterface
  311. {
  312. return $this->birthday;
  313. }
  314. public function setBirthday(?\DateTimeInterface $birthday): self
  315. {
  316. $this->birthday = $birthday;
  317. return $this;
  318. }
  319. /**
  320. * Returning a salt is only needed, if you are not using a modern
  321. * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  322. *
  323. * @see UserInterface
  324. */
  325. public function getSalt(): ?string
  326. {
  327. return $this->salt;
  328. }
  329. public function setSalt(string $salt): self
  330. {
  331. $this->salt = $salt;
  332. return $this;
  333. }
  334. public function getIslocked(): ?bool
  335. {
  336. return ($this->islocked === 'Y');
  337. }
  338. public function setIslocked(string $islocked): self
  339. {
  340. $this->islocked = $islocked;
  341. return $this;
  342. }
  343. public function getDateaccountlocked(): ?\DateTimeInterface
  344. {
  345. return $this->dateaccountlocked;
  346. }
  347. public function setDateaccountlocked(?\DateTimeInterface $dateaccountlocked): self
  348. {
  349. $this->dateaccountlocked = $dateaccountlocked;
  350. return $this;
  351. }
  352. public function getFailedlogincount(): ?int
  353. {
  354. return $this->failedlogincount;
  355. }
  356. public function setFailedlogincount(int $failedlogincount): self
  357. {
  358. $this->failedlogincount = $failedlogincount;
  359. return $this;
  360. }
  361. public function getDatepasswordchanged(): ?\DateTimeInterface
  362. {
  363. return $this->datepasswordchanged;
  364. }
  365. public function setDatepasswordchanged(?\DateTimeInterface $datepasswordchanged): self
  366. {
  367. $this->datepasswordchanged = $datepasswordchanged;
  368. return $this;
  369. }
  370. public function getDatelastlogin(): ?\DateTimeInterface
  371. {
  372. return $this->datelastlogin;
  373. }
  374. public function setDatelastlogin(?\DateTimeInterface $datelastlogin): self
  375. {
  376. $this->datelastlogin = $datelastlogin;
  377. return $this;
  378. }
  379. public function getIsexpired(): ?bool
  380. {
  381. return ($this->isexpired === 'Y');
  382. }
  383. public function setIsexpired(string $isexpired): self
  384. {
  385. $this->isexpired = $isexpired;
  386. return $this;
  387. }
  388. public function getSecurityquestion(): ?string
  389. {
  390. return $this->securityquestion;
  391. }
  392. public function setSecurityquestion(string $securityquestion): self
  393. {
  394. $this->securityquestion = $securityquestion;
  395. return $this;
  396. }
  397. public function getAnswer(): ?string
  398. {
  399. return $this->answer;
  400. }
  401. public function setAnswer(?string $answer): self
  402. {
  403. $this->answer = $answer;
  404. return $this;
  405. }
  406. public function getCBpartner(): ?CBpartner
  407. {
  408. return $this->c_bpartner;
  409. }
  410. public function setCBpartner(?CBpartner $c_bpartner): self
  411. {
  412. $this->c_bpartner = $c_bpartner;
  413. return $this;
  414. }
  415. public function getCBpartnerId(): ?int
  416. {
  417. return $this->c_bpartner_id;
  418. }
  419. public function setCBpartnerId(int $c_bpartner_id): self
  420. {
  421. $this->c_bpartner_id = $c_bpartner_id;
  422. return $this;
  423. }
  424. public function getCBpartnerLocation(): ?CBpartnerLocation
  425. {
  426. return $this->c_bpartner_location;
  427. }
  428. public function setCBpartnerLocation(?CBpartnerLocation $c_bpartner_location): self
  429. {
  430. $this->c_bpartner_location = $c_bpartner_location;
  431. return $this;
  432. }
  433. public function getCBpartnerLocationId(): ?int
  434. {
  435. return $this->c_bpartner_location_id;
  436. }
  437. public function setCBpartnerLocationId(?int $c_bpartner_location_id): self
  438. {
  439. $this->c_bpartner_location_id = $c_bpartner_location_id;
  440. return $this;
  441. }
  442. /**
  443. * @return Collection<int, AdUserRoles>
  444. */
  445. public function getAdUserRoles(): Collection
  446. {
  447. return $this->ad_user_roles;
  448. }
  449. public function addAdUserRole(AdUserRoles $adUserRole): self
  450. {
  451. if (!$this->ad_user_roles->contains($adUserRole)) {
  452. $this->ad_user_roles[] = $adUserRole;
  453. $adUserRole->setAdUser($this);
  454. }
  455. return $this;
  456. }
  457. public function removeAdUserRole(AdUserRoles $adUserRole): self
  458. {
  459. if ($this->ad_user_roles->removeElement($adUserRole)) {
  460. // set the owning side to null (unless already changed)
  461. if ($adUserRole->getAdUser() === $this) {
  462. $adUserRole->setAdUser(null);
  463. }
  464. }
  465. return $this;
  466. }
  467. /**
  468. * @see UserInterface
  469. */
  470. public function getRoles(): Array
  471. {
  472. $roles = [];
  473. $roles[] = 'ROLE_USER';
  474. return array_unique($roles);
  475. }
  476. /**
  477. * @see UserInterface
  478. */
  479. public function eraseCredentials()
  480. {
  481. // If you store any temporary, sensitive data on the user, clear it here
  482. // $this->plainPassword = null;
  483. }
  484. /**
  485. * @return Collection<int, AdUserOrgaccess>
  486. */
  487. public function getAdUserOrgaccesses(): Collection
  488. {
  489. return $this->ad_user_orgaccesses;
  490. }
  491. public function addAdUserOrgaccess(AdUserOrgaccess $adUserOrgaccess): self
  492. {
  493. if (!$this->ad_user_orgaccesses->contains($adUserOrgaccess)) {
  494. $this->ad_user_orgaccesses[] = $adUserOrgaccess;
  495. $adUserOrgaccess->setAdUser($this);
  496. }
  497. return $this;
  498. }
  499. public function removeAdUserOrgaccess(AdUserOrgaccess $adUserOrgaccess): self
  500. {
  501. if ($this->ad_user_orgaccesses->removeElement($adUserOrgaccess)) {
  502. // set the owning side to null (unless already changed)
  503. if ($adUserOrgaccess->getAdUser() === $this) {
  504. $adUserOrgaccess->setAdUser(null);
  505. }
  506. }
  507. return $this;
  508. }
  509. public function getCActivity(): ?CActivity
  510. {
  511. return $this->c_activity;
  512. }
  513. public function setCActivity(?CActivity $c_activity): self
  514. {
  515. $this->c_activity = $c_activity;
  516. return $this;
  517. }
  518. public function getCActivityId(): ?int
  519. {
  520. return $this->c_activity_id;
  521. }
  522. public function setCActivityId(?int $c_activity_id): self
  523. {
  524. $this->c_activity_id = $c_activity_id;
  525. return $this;
  526. }
  527. public function getIsSalesRep() : bool {
  528. if(!$this->salesRep) {
  529. return false;
  530. }
  531. return true;
  532. }
  533. public function getSalesRep() : ?SmSalesRep {
  534. return $this->salesRep;
  535. }
  536. }