src/JuridicusBundle/Entity/Email.php line 11

Open in your IDE?
  1. <?php
  2. namespace JF\JuridicusBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. /**
  6. * Email
  7. */
  8. class Email extends InitModeEntity
  9. {
  10. const CLASSNAME = __CLASS__;
  11. /**
  12. *
  13. */
  14. const KENNZIFFER = 1;
  15. const ERINNERUNG_1 = 2;
  16. const ERINNERUNG_2 = 3;
  17. const ERINNERUNG_3 = 4;
  18. const REGISTRIERUNG = 5;
  19. const FIRST_LOGIN = 6;
  20. const PROTOKOLL_FERTIG = 7;
  21. const MAHNUNG_GEBUEHREN_1 = 8;
  22. const MAHNUNG_GEBUEHREN_2 = 9;
  23. const MAHNUNG_GEBUEHREN_3 = 10;
  24. const MAHNUNG_STRAFE_1 = 11;
  25. const MAHNUNG_STRAFE_2 = 12;
  26. const MAHNUNG_STRAFE_3 = 13;
  27. const LAST_MINUTE = 14;
  28. const PRUEFER_PROTOKOLLE = 15;
  29. const SMS = 16;
  30. const EMPFEHLUNG = 17;
  31. const WERBUNG_ZA = 18;
  32. const WERBUNG_PR = 19;
  33. const RESETTING = 20;
  34. const SMS_RESETTING = 21;
  35. const BUCHUNG = 22;
  36. const BUCHUNG_RECHNUNG = 23;
  37. const BUCHUNG_NACHFRAGE = 24;
  38. const PROTOKOLL_DUPLIKAT = 25;
  39. const DOWNLOAD_MOEGLICH = 26;
  40. const BUCHUNG_RECHNUNG_NACHTRAG = 27;
  41. const ERINNERUNG_VERKAEUFER_1 = 28;
  42. const ERINNERUNG_VERKAEUFER_2 = 29;
  43. const ERINNERUNG_VERKAEUFER_3 = 30;
  44. const PROTOKOLL_FERTIG_ZAHLUNG = 31;
  45. const ERINNERUNG_KEINE_BUCHUNG_1 = 32;
  46. const ERINNERUNG_KEINE_BUCHUNG_2 = 33;
  47. const ERINNERUNG_KEINE_BUCHUNG_3 = 34;
  48. const MAHNUNG_STRAFE_KEINE_BUCHUNG_1 = 35;
  49. const MAHNUNG_STRAFE_KEINE_BUCHUNG_2 = 36;
  50. const MAHNUNG_STRAFE_KEINE_BUCHUNG_3 = 37;
  51. const SHOUTBOX_INFO = 38;
  52. const VERSAND_ZA_ABO = 39;
  53. const VERSAND_PR_ABO = 40;
  54. const VERSAND_RECHNUNG_ZA_ABO = 41;
  55. const VERSAND_RECHNUNG_PR_ABO = 42;
  56. const VERSAND_ZA_ABO_EINZEL = 43;
  57. const VERSAND_PR_ABO_EINZEL = 44;
  58. const VERSAND_RECHNUNG_ZA_ABO_EINZEL = 45;
  59. const VERSAND_RECHNUNG_PR_ABO_EINZEL = 46;
  60. const VERSAND_ZA_ABO_PROBE = 48;
  61. const VERSAND_PR_ABO_PROBE = 49;
  62. const VERSAND_RECHNUNG_ZA_ABO_PROBE = 50;
  63. const VERSAND_RECHNUNG_PR_ABO_PROBE = 51;
  64. const PRUEFER_BEREICH_REGISTRIERUNG = 52;
  65. const PRUEFER_BEREICH_REGISTRIERUNG_PASSWORT = 53;
  66. const PRUEFER_BEREICH_PASSWORT_RESET = 54;
  67. const PRUEFER_BEREICH_PASSWORT_RESET_PASSWORT = 55;
  68. /**
  69. * @var array
  70. * @access private
  71. */
  72. private static $typ_options = array(
  73. self::KENNZIFFER => 'Ungütlige Kennziffer',
  74. self::ERINNERUNG_1 => '1. Erinnerung',
  75. self::ERINNERUNG_2 => '2. Erinnerung',
  76. self::ERINNERUNG_3 => '3. Erinnerung',
  77. self::ERINNERUNG_VERKAEUFER_1 => '1. Erinnerung Verkäufer',
  78. self::ERINNERUNG_VERKAEUFER_2 => '2. Erinnerung Verkäufer',
  79. self::ERINNERUNG_VERKAEUFER_3 => '3. Erinnerung Verkäufer',
  80. self::REGISTRIERUNG => 'Registrierung',
  81. self::FIRST_LOGIN => 'Erst-Login',
  82. self::PROTOKOLL_FERTIG => 'Protokoll fertig',
  83. self::PROTOKOLL_FERTIG_ZAHLUNG => 'Protokoll fertig - Überweisung',
  84. self::MAHNUNG_GEBUEHREN_1 => '1. Mahnung Grundgebühr',
  85. self::MAHNUNG_GEBUEHREN_2 => '2. Mahnung Grundgebühr',
  86. self::MAHNUNG_GEBUEHREN_3 => '3. Mahnung Grundgebühr',
  87. self::MAHNUNG_STRAFE_1 => '1. Mahnung Strafgebühr',
  88. self::MAHNUNG_STRAFE_2 => '2. Mahnung Strafgebühr',
  89. self::MAHNUNG_STRAFE_3 => '3. Mahnung Strafgebühr',
  90. self::LAST_MINUTE => 'Last-Minute',
  91. self::PRUEFER_PROTOKOLLE => 'Protokollversand an Prüfer',
  92. self::SMS => 'SMS',
  93. self::EMPFEHLUNG => 'Empfehlung',
  94. self::BUCHUNG => 'Buchung',
  95. self::BUCHUNG_RECHNUNG => 'Buchung und Rechnung',
  96. self::DOWNLOAD_MOEGLICH => 'Download möglich',
  97. self::BUCHUNG_RECHNUNG_NACHTRAG => 'Rechnung nachträglich',
  98. self::BUCHUNG_NACHFRAGE => 'Nachfrage bei fehlender Buchung',
  99. self::WERBUNG_ZA => 'Werbung ZA',
  100. self::WERBUNG_PR => 'Werbung PR',
  101. self::RESETTING => 'Password-Reset',
  102. self::SMS_RESETTING => 'SMS für Password-Reset',
  103. self::PROTOKOLL_DUPLIKAT => 'Protokoll-Duplikat gefunden',
  104. self::ERINNERUNG_KEINE_BUCHUNG_1 => '1. Erinnerung bei fehlender Buchung',
  105. self::ERINNERUNG_KEINE_BUCHUNG_2 => '2. Erinnerung bei fehlender Buchung',
  106. self::ERINNERUNG_KEINE_BUCHUNG_3 => '3. Erinnerung bei fehlender Buchung',
  107. self::MAHNUNG_STRAFE_KEINE_BUCHUNG_1 => '1. Mahnung bei fehlender Buchung',
  108. self::MAHNUNG_STRAFE_KEINE_BUCHUNG_2 => '2. Mahnung bei fehlender Buchung',
  109. self::MAHNUNG_STRAFE_KEINE_BUCHUNG_3 => '3. Mahnung bei fehlender Buchung',
  110. self::SHOUTBOX_INFO => 'Information bei Shoutbox-Nachricht',
  111. self::VERSAND_PR_ABO => 'Versand einer abonnierten PR-Ausgabe (Voll/Halbjahresabo)',
  112. self::VERSAND_ZA_ABO => 'Versand einer abonnierten ZA-Ausgabe (Voll/Halbjahresabo)',
  113. self::VERSAND_RECHNUNG_PR_ABO => 'Versand einer Rechnung für ein PR-Abo (Vollabo)',
  114. self::VERSAND_RECHNUNG_ZA_ABO => 'Versand einer Rechnung für ein ZA-Abo (Vollabo)',
  115. self::VERSAND_PR_ABO_EINZEL => 'Versand einer abonnierten PR-Ausgabe (Einzelheft)',
  116. self::VERSAND_ZA_ABO_EINZEL => 'Versand einer abonnierten ZA-Ausgabe (Einzelheft)',
  117. self::VERSAND_RECHNUNG_PR_ABO_EINZEL => 'Versand einer Rechnung für ein PR-Abo (Einzelheft)',
  118. self::VERSAND_RECHNUNG_ZA_ABO_EINZEL => 'Versand einer Rechnung für ein ZA-Abo (Einzelheft)',
  119. self::VERSAND_PR_ABO_PROBE => 'Versand einer abonnierten PR-Ausgabe (Probeabo)',
  120. self::VERSAND_ZA_ABO_PROBE => 'Versand einer abonnierten ZA-Ausgabe (Probeabo)',
  121. self::VERSAND_RECHNUNG_PR_ABO_PROBE => 'Versand einer Rechnung für ein PR-Abo (Probeabo)',
  122. self::VERSAND_RECHNUNG_ZA_ABO_PROBE => 'Versand einer Rechnung für ein ZA-Abo (Probeabo)',
  123. self::PRUEFER_BEREICH_REGISTRIERUNG => 'Prüferbereich Registrierung ',
  124. self::PRUEFER_BEREICH_REGISTRIERUNG_PASSWORT => 'Prüferbereich Passwort ',
  125. self::PRUEFER_BEREICH_PASSWORT_RESET => 'Prüferbereich Passwort-Reset ',
  126. self::PRUEFER_BEREICH_PASSWORT_RESET_PASSWORT => 'Prüferbereich Passwort-Reset Passwort ',
  127. );
  128. /**
  129. * Zuordnung E-Mail-Templates Versand Abos
  130. *
  131. * @var array
  132. */
  133. private static $abo_rechnung_map = array(
  134. 'PR' => array(
  135. Abo::ABO_FULL => self::VERSAND_RECHNUNG_PR_ABO,
  136. Abo::ABO_LOCKABO_6 => self::VERSAND_RECHNUNG_PR_ABO,
  137. Abo::ABO_EINZELHEFT => self::VERSAND_RECHNUNG_PR_ABO_EINZEL,
  138. Abo::ABO_LESEPROBE_GRATIS => self::VERSAND_RECHNUNG_PR_ABO_EINZEL,
  139. Abo::ABO_PROBE_3 => self::VERSAND_RECHNUNG_PR_ABO_PROBE,
  140. ),
  141. 'ZA' => array(
  142. Abo::ABO_FULL => self::VERSAND_RECHNUNG_ZA_ABO,
  143. Abo::ABO_LOCKABO_6 => self::VERSAND_RECHNUNG_ZA_ABO,
  144. Abo::ABO_EINZELHEFT => self::VERSAND_RECHNUNG_ZA_ABO_EINZEL,
  145. Abo::ABO_LESEPROBE_GRATIS => self::VERSAND_RECHNUNG_ZA_ABO_EINZEL,
  146. Abo::ABO_PROBE_3 => self::VERSAND_RECHNUNG_ZA_ABO_PROBE,
  147. )
  148. );
  149. /**
  150. * Zuordnung E-Mail-Templates Rechnungen Abos
  151. * @var array
  152. */
  153. private static $abo_versand_map = array(
  154. 'PR' => array(
  155. Abo::ABO_FULL => self::VERSAND_PR_ABO,
  156. Abo::ABO_LOCKABO_6 => self::VERSAND_PR_ABO,
  157. Abo::ABO_EINZELHEFT => self::VERSAND_PR_ABO_EINZEL,
  158. Abo::ABO_LESEPROBE_GRATIS => self::VERSAND_PR_ABO_EINZEL,
  159. Abo::ABO_PROBE_3 => self::VERSAND_PR_ABO_PROBE,
  160. ),
  161. 'ZA' => array(
  162. Abo::ABO_FULL => self::VERSAND_ZA_ABO,
  163. Abo::ABO_LOCKABO_6 => self::VERSAND_ZA_ABO,
  164. Abo::ABO_EINZELHEFT => self::VERSAND_ZA_ABO_EINZEL,
  165. Abo::ABO_LESEPROBE_GRATIS => self::VERSAND_ZA_ABO_EINZEL,
  166. Abo::ABO_PROBE_3 => self::VERSAND_ZA_ABO_PROBE,
  167. )
  168. );
  169. /**
  170. * @return array typ options
  171. */
  172. public static function getTypOptions()
  173. {
  174. return self::$typ_options;
  175. }
  176. /**
  177. * @return array typ keys
  178. */
  179. public static function getTypKeys()
  180. {
  181. return array_keys(self::$typ_options);
  182. }
  183. /**
  184. * @var integer
  185. */
  186. private $id;
  187. /**
  188. * @var integer
  189. * @Assert\NotNull
  190. * @Assert\Choice(callback="getTypKeys")
  191. */
  192. private $typ;
  193. /**
  194. * @var \DateTime
  195. * @Assert\Type(\DateTimeInterface::class)
  196. */
  197. private $created_at;
  198. /**
  199. * @var \JF\JuridicusBundle\Entity\Kunde
  200. * @Assert\Valid()
  201. */
  202. private $kunde;
  203. /**
  204. * @var \JF\JuridicusBundle\Entity\Pruefer
  205. * @Assert\Valid()
  206. */
  207. private $pruefer;
  208. /**
  209. * @var \JF\JuridicusBundle\Entity\KundePruefung
  210. * @Assert\Valid()
  211. */
  212. private $kunde_pruefung;
  213. /**
  214. * @var \JF\JuridicusBundle\Entity\ProtokollInfothekPruefer
  215. */
  216. private $protokoll_infothek_pruefer;
  217. /**
  218. * @var \JF\JuridicusBundle\Entity\Abo
  219. */
  220. private $abo;
  221. /**
  222. * Get id
  223. *
  224. * @return integer
  225. */
  226. public function getId()
  227. {
  228. return $this->id;
  229. }
  230. /**
  231. * Set typ
  232. *
  233. * @param integer $typ
  234. * @return Email
  235. */
  236. public function setTyp($typ)
  237. {
  238. $this->typ = $typ;
  239. return $this;
  240. }
  241. /**
  242. * Get typ
  243. *
  244. * @return int
  245. */
  246. public function getTyp()
  247. {
  248. return $this->typ;
  249. }
  250. /**
  251. * Get typ string
  252. *
  253. * @return string
  254. */
  255. public function getTypString()
  256. {
  257. if (isset(self::$typ_options[$this->getTyp()])) {
  258. return self::$typ_options[$this->getTyp()];
  259. } else {
  260. return 'nicht verfügbar';
  261. }
  262. }
  263. /**
  264. *
  265. * @return string
  266. */
  267. public function getTypAndTime()
  268. {
  269. if (isset($this->created_at)) {
  270. return sprintf('%s (%s)', $this->getTypString(),
  271. $this->created_at->format('d.m.Y H:i:s'));
  272. } else {
  273. return $this->getTypString();
  274. }
  275. }
  276. /**
  277. * Set created_at
  278. *
  279. * @param \DateTime $createdAt
  280. * @return Email
  281. */
  282. public function setCreatedAt(\DateTime $createdAt = null)
  283. {
  284. $this->created_at = $createdAt;
  285. return $this;
  286. }
  287. /**
  288. * Get created_at
  289. *
  290. * @return \DateTime
  291. */
  292. public function getCreatedAt()
  293. {
  294. return $this->created_at;
  295. }
  296. /**
  297. * Set kunde [OWNING SIDE]
  298. *
  299. * @param \JF\JuridicusBundle\Entity\Kunde $kunde
  300. * @return Email
  301. */
  302. public function setKunde(Kunde $kunde = null)
  303. {
  304. $this->kunde = $kunde;
  305. return $this;
  306. }
  307. /**
  308. * Get kunde
  309. *
  310. * @return \JF\JuridicusBundle\Entity\Kunde
  311. */
  312. public function getKunde()
  313. {
  314. return $this->kunde;
  315. }
  316. /**
  317. * Set pruefer
  318. *
  319. * @param \JF\JuridicusBundle\Entity\Pruefer $pruefer
  320. * @return Email
  321. */
  322. public function setPruefer(Pruefer $pruefer = null)
  323. {
  324. $this->pruefer = $pruefer;
  325. return $this;
  326. }
  327. /**
  328. * Get pruefer
  329. *
  330. * @return \JF\JuridicusBundle\Entity\Pruefer
  331. */
  332. public function getPruefer()
  333. {
  334. return $this->pruefer;
  335. }
  336. /**
  337. * Set kunde_pruefung
  338. *
  339. * @param \JF\JuridicusBundle\Entity\KundePruefung $kundePruefung
  340. * @return Email
  341. */
  342. public function setKundePruefung(KundePruefung $kundePruefung = null)
  343. {
  344. $this->kunde_pruefung = $kundePruefung;
  345. return $this;
  346. }
  347. /**
  348. * Get kunde_pruefung
  349. *
  350. * @return \JF\JuridicusBundle\Entity\KundePruefung
  351. */
  352. public function getKundePruefung()
  353. {
  354. return $this->kunde_pruefung;
  355. }
  356. /**
  357. * @ORM\PrePersist
  358. */
  359. public function setCreatedAtValue()
  360. {
  361. if (!$this->init_mode AND ! isset($this->created_at)) {
  362. $this->setCreatedAt(new \DateTime());
  363. }
  364. }
  365. /**
  366. * String representation
  367. *
  368. * @return string
  369. */
  370. public function __toString()
  371. {
  372. return $this->getTypAndTime();
  373. }
  374. /**
  375. * Set protokoll_infothek_pruefer
  376. *
  377. * @param \JF\JuridicusBundle\Entity\ProtokollInfothekPruefer $protokollInfothekPruefer
  378. * @return Email
  379. */
  380. public function setProtokollInfothekPruefer(ProtokollInfothekPruefer $protokollInfothekPruefer
  381. = null)
  382. {
  383. $this->protokoll_infothek_pruefer = $protokollInfothekPruefer;
  384. return $this;
  385. }
  386. /**
  387. * Get protokoll_infothek_pruefer
  388. *
  389. * @return \JF\JuridicusBundle\Entity\ProtokollInfothekPruefer
  390. */
  391. public function getProtokollInfothekPruefer()
  392. {
  393. return $this->protokoll_infothek_pruefer;
  394. }
  395. /**
  396. * Set abo
  397. *
  398. * @param \JF\JuridicusBundle\Entity\Abo $abo
  399. * @return Email
  400. */
  401. public function setAbo(Abo $abo = null)
  402. {
  403. $this->abo = $abo;
  404. return $this;
  405. }
  406. /**
  407. *
  408. * @return Email
  409. */
  410. public function calculateRechnungTyp()
  411. {
  412. $abo = $this->getAbo();
  413. if (!$abo) {
  414. return $this;
  415. }
  416. $this->typ = self::$abo_rechnung_map[$abo->getZeitschrift()][$abo->getTyp()];
  417. return $this;
  418. }
  419. /**
  420. *
  421. * @return Email
  422. */
  423. public function calculateVersandTyp()
  424. {
  425. $abo = $this->getAbo();
  426. if (!$abo) {
  427. return $this;
  428. }
  429. $this->typ = self::$abo_versand_map[$abo->getZeitschrift()][$abo->getTyp()];
  430. return $this;
  431. }
  432. /**
  433. * Get abo
  434. *
  435. * @return \JF\JuridicusBundle\Entity\Abo
  436. */
  437. public function getAbo()
  438. {
  439. return $this->abo;
  440. }
  441. }