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