src/AdminBundle/Entity/Company.php line 13

Open in your IDE?
  1. <?php
  2. namespace AdminBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * Company
  7. */
  8. #[ORM\Table(name: 'company')]
  9. #[ORM\Entity(repositoryClass: \AdminBundle\Repository\CompanyRepository::class)]
  10. class Company extends BaseEntity
  11. {
  12. const PAYMENT_TYPE_CASH = 1;
  13. const PAYMENT_TYPE_CARD = 2;
  14. const PAYMENT_TYPE_DEPOSIT = 3;
  15. const PAYMENT_TYPE_ACCOUNT = 6;
  16. const PAYMENT_TYPE = [
  17. self::PAYMENT_TYPE_CASH => 'Cash',
  18. self::PAYMENT_TYPE_CARD => 'Card',
  19. self::PAYMENT_TYPE_DEPOSIT => 'Deposit + Cash',
  20. self::PAYMENT_TYPE_ACCOUNT => 'Account'
  21. ];
  22. const CONFIG_BOOKING_EMAIL_NONE = 0; // don't send any copy of emails
  23. const CONFIG_BOOKING_EMAIL_CONFIRMATION = 1; // send copy of booking confirmation emails
  24. const CONFIG_BOOKING_EMAIL_ALL = 99; // send copy of all booking types of emails
  25. const CONFIG_BOOKING_EMAIL = [
  26. self::CONFIG_BOOKING_EMAIL_NONE => 'N\A',
  27. self::CONFIG_BOOKING_EMAIL_CONFIRMATION => 'Just confirmation emails',
  28. self::CONFIG_BOOKING_EMAIL_ALL => 'All emails'
  29. ];
  30. const INVOICE_TYPE_WEEKLY = 1;
  31. const INVOICE_TYPE_MONTHLY = 2;
  32. const INVOICE_TYPE = [
  33. self::INVOICE_TYPE_WEEKLY => 'Weekly',
  34. self::INVOICE_TYPE_MONTHLY => 'Monthly',
  35. ];
  36. /**
  37. * @var int
  38. */
  39. #[ORM\Column(name: 'id', type: 'integer')]
  40. #[ORM\Id]
  41. #[ORM\GeneratedValue(strategy: 'AUTO')]
  42. private $id;
  43. /**
  44. * @var string
  45. */
  46. #[ORM\Column(name: 'business_name', type: 'string', length: 255)]
  47. private $businessName;
  48. /**
  49. * @var string
  50. */
  51. #[ORM\Column(name: 'ref', type: 'string', length: 255)]
  52. private $ref;
  53. /**
  54. * @var string
  55. */
  56. #[ORM\Column(name: 'organization_name', type: 'string', length: 255)]
  57. private $organizationName;
  58. /**
  59. * @var string
  60. */
  61. #[ORM\Column(name: 'main_contact_name', type: 'string', length: 255)]
  62. private $mainContactName;
  63. /**
  64. * @var string
  65. */
  66. #[ORM\Column(name: 'ba_address1', type: 'string', length: 255)]
  67. private $baAddress1;
  68. /**
  69. * @var string
  70. */
  71. #[ORM\Column(name: 'ba_address2', type: 'string', length: 255, nullable: true)]
  72. private $baAddress2;
  73. /**
  74. * @var string
  75. */
  76. #[ORM\Column(name: 'ba_door_number', type: 'string', length: 255, nullable: true)]
  77. private $baDoorNumber;
  78. /**
  79. * @var string
  80. */
  81. #[ORM\Column(name: 'ba_store_apt', type: 'string', length: 255, nullable: true)]
  82. private $baStoreApt;
  83. /**
  84. * @var string
  85. */
  86. #[ORM\Column(name: 'ba_city', type: 'string', length: 255)]
  87. private $baCity;
  88. /**
  89. * @var string
  90. */
  91. #[ORM\Column(name: 'ba_postcode', type: 'string', length: 255)]
  92. private $baPostcode;
  93. /**
  94. * @var string
  95. */
  96. #[ORM\Column(name: 'ba_country', type: 'string', length: 255)]
  97. private $baCountry;
  98. /**
  99. * @var string
  100. */
  101. #[ORM\Column(name: 'vat_id', type: 'string', length: 255)]
  102. private $vatId;
  103. /**
  104. * @var string
  105. */
  106. #[ORM\Column(name: 'notes', type: 'text', nullable: true)]
  107. private $notes;
  108. /**
  109. * @var int
  110. */
  111. #[ORM\Column(name: 'config_booking_emails', type: 'smallint', options: ['default' => 0])]
  112. private $configBookingEmails = self::CONFIG_BOOKING_EMAIL_NONE;
  113. /**
  114. * @var float
  115. */
  116. #[ORM\Column(name: 'price_discount', type: 'float')]
  117. private $priceDiscount;
  118. /**
  119. * @var bool
  120. */
  121. #[ORM\Column(name: 'price_discount_fixed', type: 'boolean')]
  122. private $priceDiscountFixed = false;
  123. /**
  124. * @var integer
  125. */
  126. #[ORM\Column(name: 'payment_type', type: 'smallint', length: 20)]
  127. private $paymentType;
  128. /**
  129. * @var ArrayCollection
  130. */
  131. #[ORM\OneToMany(targetEntity: \Account::class, mappedBy: 'company', cascade: ['persist'], orphanRemoval: true)]
  132. private $accounts;
  133. /**
  134. * @var User
  135. */
  136. #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'SET NULL')]
  137. #[ORM\OneToOne(targetEntity: \User::class, inversedBy: 'company', cascade: ['all'])]
  138. protected $user;
  139. /**
  140. * @var ClientInvoices
  141. */
  142. #[ORM\OneToMany(targetEntity: \AdminBundle\Entity\ClientInvoices::class, mappedBy: 'company', cascade: ['persist', 'remove'], orphanRemoval: true)]
  143. protected $clientInvoices;
  144. /**
  145. * @var Company
  146. */
  147. #[ORM\OneToMany(targetEntity: \AdminBundle\Entity\CompanyInvoice::class, mappedBy: 'company', cascade: ['persist', 'remove'], orphanRemoval: true)]
  148. private $companyInvoices;
  149. /**
  150. * @var integer
  151. */
  152. #[ORM\Column(name: 'company_invoice_type', type: 'smallint', length: 20, options: ['default' => 1])]
  153. private $companyInvoiceType = self::INVOICE_TYPE_WEEKLY;
  154. public function __construct()
  155. {
  156. $this->accounts = new ArrayCollection();
  157. $this->clientInvoices = new ArrayCollection();
  158. $this->companyInvoices = new ArrayCollection();
  159. }
  160. /**
  161. * Get id
  162. *
  163. * @return int
  164. */
  165. public function getId()
  166. {
  167. return $this->id;
  168. }
  169. /**
  170. * @return ArrayCollection
  171. */
  172. public function getAccounts()
  173. {
  174. return $this->accounts;
  175. }
  176. /**
  177. * @param ArrayCollection $accounts
  178. * @return Company
  179. */
  180. public function setAccounts($accounts)
  181. {
  182. $this->accounts = $accounts;
  183. return $this;
  184. }
  185. /**
  186. * @param Account $account
  187. * @return $this
  188. */
  189. public function addAccount($account) {
  190. $this->accounts->add($account);
  191. return $this;
  192. }
  193. /**
  194. * @param Account $account
  195. * @return $this
  196. */
  197. public function removeAccount(Account $account) {
  198. $this->accounts->remove($account);
  199. return $this;
  200. }
  201. /**
  202. * Set businessName
  203. *
  204. * @param string $businessName
  205. *
  206. * @return Company
  207. */
  208. public function setBusinessName($businessName)
  209. {
  210. $this->businessName = $businessName;
  211. return $this;
  212. }
  213. /**
  214. * Get businessName
  215. *
  216. * @return string
  217. */
  218. public function getBusinessName()
  219. {
  220. return $this->businessName;
  221. }
  222. /**
  223. * Set ref
  224. *
  225. * @param string $ref
  226. *
  227. * @return Company
  228. */
  229. public function setRef($ref)
  230. {
  231. $this->ref = $ref;
  232. return $this;
  233. }
  234. /**
  235. * Get ref
  236. *
  237. * @return string
  238. */
  239. public function getRef()
  240. {
  241. return $this->ref;
  242. }
  243. /**
  244. * @return int
  245. */
  246. public function getPaymentType()
  247. {
  248. return $this->paymentType;
  249. }
  250. /**
  251. * @param int $paymentType
  252. */
  253. public function setPaymentType($paymentType)
  254. {
  255. $this->paymentType = $paymentType;
  256. }
  257. /**
  258. * Set organizationName
  259. *
  260. * @param string $organizationName
  261. *
  262. * @return Company
  263. */
  264. public function setOrganizationName($organizationName)
  265. {
  266. $this->organizationName = $organizationName;
  267. return $this;
  268. }
  269. /**
  270. * Get organizationName
  271. *
  272. * @return string
  273. */
  274. public function getOrganizationName()
  275. {
  276. return $this->organizationName;
  277. }
  278. /**
  279. * Set mainContactName
  280. *
  281. * @param string $mainContactName
  282. *
  283. * @return Company
  284. */
  285. public function setMainContactName($mainContactName)
  286. {
  287. $this->mainContactName = $mainContactName;
  288. return $this;
  289. }
  290. /**
  291. * Get mainContactName
  292. *
  293. * @return string
  294. */
  295. public function getMainContactName()
  296. {
  297. return $this->mainContactName;
  298. }
  299. /**
  300. * Set baAddress1
  301. *
  302. * @param string $baAddress1
  303. *
  304. * @return Company
  305. */
  306. public function setBaAddress1($baAddress1)
  307. {
  308. $this->baAddress1 = $baAddress1;
  309. return $this;
  310. }
  311. /**
  312. * Get baAddress1
  313. *
  314. * @return string
  315. */
  316. public function getBaAddress1()
  317. {
  318. return $this->baAddress1;
  319. }
  320. /**
  321. * Set baAddress2
  322. *
  323. * @param string $baAddress2
  324. *
  325. * @return Company
  326. */
  327. public function setBaAddress2($baAddress2)
  328. {
  329. $this->baAddress2 = $baAddress2;
  330. return $this;
  331. }
  332. /**
  333. * Get baAddress2
  334. *
  335. * @return string
  336. */
  337. public function getBaAddress2()
  338. {
  339. return $this->baAddress2;
  340. }
  341. /**
  342. * Set baDoorNumber
  343. *
  344. * @param string $baDoorNumber
  345. *
  346. * @return Company
  347. */
  348. public function setBaDoorNumber($baDoorNumber)
  349. {
  350. $this->baDoorNumber = $baDoorNumber;
  351. return $this;
  352. }
  353. /**
  354. * Get baDoorNumber
  355. *
  356. * @return string
  357. */
  358. public function getBaDoorNumber()
  359. {
  360. return $this->baDoorNumber;
  361. }
  362. /**
  363. * Set baStoreApt
  364. *
  365. * @param string $baStoreApt
  366. *
  367. * @return Company
  368. */
  369. public function setBaStoreApt($baStoreApt)
  370. {
  371. $this->baStoreApt = $baStoreApt;
  372. return $this;
  373. }
  374. /**
  375. * Get baStoreApt
  376. *
  377. * @return string
  378. */
  379. public function getBaStoreApt()
  380. {
  381. return $this->baStoreApt;
  382. }
  383. /**
  384. * Set baCity
  385. *
  386. * @param string $baCity
  387. *
  388. * @return Company
  389. */
  390. public function setBaCity($baCity)
  391. {
  392. $this->baCity = $baCity;
  393. return $this;
  394. }
  395. /**
  396. * Get baCity
  397. *
  398. * @return string
  399. */
  400. public function getBaCity()
  401. {
  402. return $this->baCity;
  403. }
  404. /**
  405. * Set baPostcode
  406. *
  407. * @param string $baPostcode
  408. *
  409. * @return Company
  410. */
  411. public function setBaPostcode($baPostcode)
  412. {
  413. $this->baPostcode = $baPostcode;
  414. return $this;
  415. }
  416. /**
  417. * Get baPostcode
  418. *
  419. * @return string
  420. */
  421. public function getBaPostcode()
  422. {
  423. return $this->baPostcode;
  424. }
  425. /**
  426. * Set baCountry
  427. *
  428. * @param string $baCountry
  429. *
  430. * @return Company
  431. */
  432. public function setBaCountry($baCountry)
  433. {
  434. $this->baCountry = $baCountry;
  435. return $this;
  436. }
  437. /**
  438. * Get baCountry
  439. *
  440. * @return string
  441. */
  442. public function getBaCountry()
  443. {
  444. return $this->baCountry;
  445. }
  446. /**
  447. * Set vatId
  448. *
  449. * @param string $vatId
  450. *
  451. * @return Company
  452. */
  453. public function setVatId($vatId)
  454. {
  455. $this->vatId = $vatId;
  456. return $this;
  457. }
  458. /**
  459. * Get vatId
  460. *
  461. * @return string
  462. */
  463. public function getVatId()
  464. {
  465. return $this->vatId;
  466. }
  467. /**
  468. * Set notes
  469. *
  470. * @param string $notes
  471. *
  472. * @return Company
  473. */
  474. public function setNotes($notes)
  475. {
  476. $this->notes = $notes;
  477. return $this;
  478. }
  479. /**
  480. * Get notes
  481. *
  482. * @return string
  483. */
  484. public function getNotes()
  485. {
  486. return $this->notes;
  487. }
  488. /**
  489. * Set priceDiscount
  490. *
  491. * @param float $priceDiscount
  492. *
  493. * @return Company
  494. */
  495. public function setPriceDiscount($priceDiscount)
  496. {
  497. $this->priceDiscount = $priceDiscount;
  498. return $this;
  499. }
  500. /**
  501. * Get priceDiscount
  502. *
  503. * @return float
  504. */
  505. public function getPriceDiscount()
  506. {
  507. return $this->priceDiscount;
  508. }
  509. /**
  510. * Set priceDiscountFixed
  511. *
  512. * @param boolean $priceDiscountFixed
  513. *
  514. * @return Company
  515. */
  516. public function setPriceDiscountFixed($priceDiscountFixed)
  517. {
  518. $this->priceDiscountFixed = $priceDiscountFixed;
  519. return $this;
  520. }
  521. /**
  522. * Get priceDiscountFixed
  523. *
  524. * @return bool
  525. */
  526. public function getPriceDiscountFixed()
  527. {
  528. return $this->priceDiscountFixed;
  529. }
  530. /**
  531. * @return User
  532. */
  533. public function getUser()
  534. {
  535. return $this->user;
  536. }
  537. /**
  538. * @param User $user
  539. * @return Company
  540. */
  541. public function setUser($user)
  542. {
  543. $this->user = $user;
  544. return $this;
  545. }
  546. /**
  547. * @return int
  548. */
  549. public function getConfigBookingEmails()
  550. {
  551. return $this->configBookingEmails;
  552. }
  553. /**
  554. * @param $configBookingEmails
  555. * @return Company
  556. */
  557. public function setConfigBookingEmails($configBookingEmails)
  558. {
  559. $this->configBookingEmails = $configBookingEmails;
  560. return $this;
  561. }
  562. public function getPriceDiscountDisplay($currencySymbol = '£')
  563. {
  564. return $this->priceDiscount.($this->priceDiscountFixed ? $currencySymbol : '%' );
  565. }
  566. public function __toString()
  567. {
  568. return '['.$this->getId().']['.$this->vatId.']'.$this->getBusinessName().' - '. $this->getOrganizationName().
  569. ' ( '. $this->getRef() .' )';
  570. }
  571. public function getClientInvoices()
  572. {
  573. return $this->clientInvoices;
  574. }
  575. public function addClientInvoices(ClientInvoices $clientInvoices)
  576. {
  577. $this->clientInvoices->add($clientInvoices);
  578. }
  579. public function getCompanyInvoices()
  580. {
  581. return $this->companyInvoices;
  582. }
  583. public function addCompanyInvoice(CompanyInvoice $companyInvoice)
  584. {
  585. $this->companyInvoices->add($companyInvoice);
  586. }
  587. /**
  588. * @return int
  589. */
  590. public function getCompanyInvoiceType()
  591. {
  592. return $this->companyInvoiceType;
  593. }
  594. /**
  595. * @param int $companyInvoiceType
  596. */
  597. public function setCompanyInvoiceType($companyInvoiceType)
  598. {
  599. $this->companyInvoiceType = $companyInvoiceType;
  600. }
  601. }