src/Daikin/BaseBundle/Entity/Company.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Daikin\BaseBundle\Entity;
  3. use App\Daikin\BaseBundle\Entity\Survey\ProtocolGroup;
  4. use DateTime;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use EHC\HTMLIdableBundle\Interfaces\HTMLIdableInterface;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Daikin\BaseBundle\Repository\CompanyRepository")
  12.  * @ORM\Table(name="company")
  13.  * @UniqueEntity("name")
  14.  */
  15. class Company extends AbstractDeleteableEntity implements HTMLIdableInterface
  16. {
  17.     /**
  18.      * aus 00 => + oder + an Anfang wenn nicht vorhanden
  19.      * @var bool
  20.      */
  21.     protected $addMissingPlusPhone true;
  22.     /**
  23.      * @ORM\Id
  24.      * @ORM\Column(type="integer")
  25.      * @ORM\GeneratedValue(strategy="AUTO")
  26.      *
  27.      * @var integer $id
  28.      */
  29.     protected $id;
  30.     /**
  31.      * @ORM\Column(type="string", name="name", unique=true)
  32.      *
  33.      * @var string $name
  34.      */
  35.     protected $name;
  36.     /**
  37.      * @Gedmo\Timestampable(on="create")
  38.      * @ORM\Column(type="integer", name="created_at")
  39.      *
  40.      * @var integer $createdAt
  41.      */
  42.     protected $createdAt;
  43.     /**
  44.      * @Gedmo\Timestampable(on="update")
  45.      * @ORM\Column(type="integer", name="updated_at")
  46.      *
  47.      * @var integer $updatedAt
  48.      */
  49.     protected $updatedAt;
  50.     /**
  51.      * @ORM\Column(type="string", name="street")
  52.      *
  53.      * @var string $street
  54.      */
  55.     protected $street;
  56.     /**
  57.      * @ORM\Column(length=6)
  58.      *
  59.      * @var string $zipcode
  60.      */
  61.     protected $zipcode;
  62.     /**
  63.      * @ORM\Column(type="string", name="city")
  64.      *
  65.      * @var string $city
  66.      */
  67.     protected $city;
  68.     /**
  69.      * @ORM\Column(type="string", name="telephone", nullable=true)
  70.      *
  71.      * @var string $telephone
  72.      */
  73.     protected $telephone;
  74.     /**
  75.      * @ORM\OneToMany(targetEntity="User", mappedBy="company")
  76.      *
  77.      *  @var ArrayCollection $users
  78.      */
  79.     protected $users;
  80.     /**
  81.      * @ORM\OneToMany(targetEntity="Objects", mappedBy="company")
  82.     */
  83.     protected $objects;
  84.     /**
  85.      * @ORM\Column(length=10, nullable=true, unique=true)
  86.      */
  87.     protected $sapnumber;
  88.     /**
  89.      * @var ArrayCollection|ProtocolGroup[]
  90.      * @ORM\ManyToMany(targetEntity="App\Daikin\BaseBundle\Entity\Survey\ProtocolGroup", mappedBy="companies")
  91.      */
  92.     protected $protocol_groups;
  93.     /**
  94.      * @ORM\OneToOne(targetEntity="App\Daikin\BaseBundle\Entity\CompanyCertificate", mappedBy="company", cascade={"persist"}, orphanRemoval=true)
  95.      */
  96.     protected $certificate;
  97.     /**
  98.      * Datum der Bestätigung von "Bedingungen der Bestellung von R410A Kältemittel"
  99.      *
  100.      * @ORM\Column(name="refShopAcceptedConditions", type="datetime", nullable=true)
  101.      */
  102.     protected $refShopAcceptedConditions;
  103.     /**
  104.      * @var User
  105.      * @ORM\ManyToOne(targetEntity="App\Daikin\BaseBundle\Entity\User")
  106.      * @ORM\JoinColumn(name="userAcceptedConditions_id", onDelete="SET NULL")
  107.      */
  108.     private $userAcceptedConditions;
  109.     /**
  110.      * @var DateTime
  111.      *
  112.      * @ORM\Column(type="datetime", nullable=true)
  113.      */
  114.     protected $converted_from_rotex;
  115.     /**
  116.      * @var int
  117.      *
  118.      * @ORM\Column(type="integer", nullable=true)
  119.      */
  120.     protected $converted_from_rotex_company_id;
  121.     /**
  122.      * Conructor for class
  123.      */
  124.     public function __construct()
  125.     {
  126.       parent::__construct();
  127.       $this->users = new ArrayCollection();
  128.       $this->objects = new ArrayCollection();
  129.       $this->protocol_groups = new  ArrayCollection;
  130.       $this->createdAt time();
  131.       $this->updatedAt time();
  132.     }
  133.     public function __toString()
  134.     {
  135.       return $this->getName();
  136.     }
  137.     /**
  138.      * Get id
  139.      *
  140.      * @return integer
  141.      */
  142.     public function getId()
  143.     {
  144.         return $this->id;
  145.     }
  146.     public function getHTMLId()
  147.     {
  148.       return 'company-'.$this->id;
  149.     }
  150.     /**
  151.      * Set name
  152.      *
  153.      * @param string $name
  154.      * @return Company
  155.      */
  156.     public function setName($name)
  157.     {
  158.         $this->name $name;
  159.         return $this;
  160.     }
  161.     /**
  162.      * Get name
  163.      *
  164.      * @return string
  165.      */
  166.     public function getName()
  167.     {
  168.         return $this->name;
  169.     }
  170.     /**
  171.      * Set createdAt
  172.      *
  173.      * @param int $createdAt
  174.      */
  175.     public function setCreatedAt($createdAt)
  176.     {
  177.         $this->createdAt $createdAt;
  178.     }
  179.     /**
  180.      * Get createdAt
  181.      *
  182.      * @return int
  183.      */
  184.     public function getCreatedAt()
  185.     {
  186.         return $this->createdAt;
  187.     }
  188.     /**
  189.      * Set updatedAt
  190.      *
  191.      * @param integer $updatedAt
  192.      * @return Company
  193.      */
  194.     public function setUpdatedAt($updatedAt)
  195.     {
  196.         $this->updatedAt $updatedAt;
  197.         return $this;
  198.     }
  199.     /**
  200.      * Get updatedAt
  201.      *
  202.      * @return integer
  203.      */
  204.     public function getUpdatedAt()
  205.     {
  206.         return $this->updatedAt;
  207.     }
  208.     /**
  209.      * Set street
  210.      *
  211.      * @param string $street
  212.      * @return Company
  213.      */
  214.     public function setStreet($street)
  215.     {
  216.         $this->street $street;
  217.         return $this;
  218.     }
  219.     /**
  220.      * Get street
  221.      *
  222.      * @return string
  223.      */
  224.     public function getStreet()
  225.     {
  226.         return $this->street;
  227.     }
  228.     /**
  229.      * Set zipcode
  230.      *
  231.      * @param string $zipcode
  232.      * @return Company
  233.      */
  234.     public function setZipcode($zipcode)
  235.     {
  236.         $this->zipcode $zipcode;
  237.         return $this;
  238.     }
  239.     /**
  240.      * Get zipcode
  241.      *
  242.      * @return string
  243.      */
  244.     public function getZipcode()
  245.     {
  246.         return $this->zipcode sprintf('%0'.mb_strlen($this->zipcode).'d'$this->zipcode) : null;
  247.     }
  248.     /**
  249.      * Set city
  250.      *
  251.      * @param string $city
  252.      * @return Company
  253.      */
  254.     public function setCity($city)
  255.     {
  256.         $this->city $city;
  257.         return $this;
  258.     }
  259.     /**
  260.      * Get city
  261.      *
  262.      * @return string
  263.      */
  264.     public function getCity()
  265.     {
  266.         return $this->city;
  267.     }
  268.     /**
  269.      * @return bool
  270.      */
  271.     public function isAddMissingPlusPhone()
  272.     {
  273.         return $this->addMissingPlusPhone;
  274.     }
  275.     /**
  276.      * @param bool $addMissingPlusPhone
  277.      * @return Company
  278.      */
  279.     public function setAddMissingPlusPhone($addMissingPlusPhone)
  280.     {
  281.         $this->addMissingPlusPhone $addMissingPlusPhone;
  282.         return $this;
  283.     }
  284.     /**
  285.      * Set telephone
  286.      *
  287.      * @param string $telephone
  288.      * @return Company
  289.      */
  290.     public function setTelephone($telephone)
  291.     {
  292.         if ($this->isAddMissingPlusPhone()) {
  293.             $telephone preg_replace'#^00#''+'$telephone );
  294.             $this->telephone = ( strpos$telephone'+' ) === ) ? $telephone '+'.$telephone;
  295.         }else{
  296.             $this->telephone $telephone;
  297.         }
  298.         return $this;
  299.     }
  300.     /**
  301.      * Get telephone
  302.      *
  303.      * @return string
  304.      */
  305.     public function getTelephone()
  306.     {
  307.         return $this->telephone;
  308.     }
  309.     /**
  310.      * Get users
  311.      *
  312.      * @return ArrayCollection|User[]
  313.      */
  314.     public function getUsers()
  315.     {
  316.         return $this->users;
  317.     }
  318.     /**
  319.      * Get objects
  320.      *
  321.      * @return ArrayCollection|Objects[]
  322.      */
  323.     public function getObjects()
  324.     {
  325.         return $this->objects;
  326.     }
  327.     /**
  328.      * set the SAP number
  329.      *
  330.      * @param string $sapnumber
  331.      * @return Company
  332.      */
  333.     public function setSapnumber$sapnumber null )
  334.     {
  335.       $this->sapnumber $sapnumber;
  336.       return $this;
  337.     }
  338.     /**
  339.      * get the SAP number
  340.      *
  341.      * @return string
  342.      */
  343.     public function getSapnumber()
  344.     {
  345.       return $this->sapnumber;
  346.     }
  347.     /**
  348.      * @return ProtocolGroup[]|ArrayCollection
  349.      */
  350.     public function getProcolGroups()
  351.     {
  352.         return $this->protocol_groups;
  353.     }
  354.     /**
  355.      * @return CompanyCertificate
  356.      */
  357.     public function getCertificate()
  358.     {
  359.         return $this->certificate;
  360.     }
  361.     /**
  362.      * @param mixed $certificate
  363.      * @return Company
  364.      */
  365.     public function setCertificate($certificate)
  366.     {
  367.         $this->certificate $certificate;
  368.         return $this;
  369.     }
  370.     /**
  371.      * @return DateTime
  372.      */
  373.     public function getRefShopAcceptedConditions()
  374.     {
  375.         return $this->refShopAcceptedConditions;
  376.     }
  377.     /**
  378.      * @return bool
  379.      */
  380.     public function hasRefShopAcceptedConditions()
  381.     {
  382.         return $this->refShopAcceptedConditions instanceof DateTime;
  383.     }
  384.     /**
  385.      * @param mixed $refShopAcceptedConditions
  386.      * @return Company
  387.      */
  388.     public function setRefShopAcceptedConditions(DateTime $refShopAcceptedConditions)
  389.     {
  390.         $this->refShopAcceptedConditions $refShopAcceptedConditions;
  391.         return $this;
  392.     }
  393.     /**
  394.      * @return Company
  395.      */
  396.     public function initRefShopAcceptedConditions()
  397.     {
  398.         if (!$this->refShopAcceptedConditions) {
  399.             $this->refShopAcceptedConditions = new DateTime();
  400.         }
  401.         return $this;
  402.     }
  403.     /**
  404.      * @return User
  405.      */
  406.     public function getUserAcceptedConditions()
  407.     {
  408.         return $this->userAcceptedConditions;
  409.     }
  410.     /**
  411.      * @param User $userAcceptedConditions
  412.      * @return Company
  413.      */
  414.     public function setUserAcceptedConditions($userAcceptedConditions)
  415.     {
  416.         $this->userAcceptedConditions $userAcceptedConditions;
  417.         return $this;
  418.     }
  419.     /**
  420.      * @return ProtocolGroup[]|ArrayCollection
  421.      */
  422.     public function getProtocolGroups()
  423.     {
  424.         return $this->protocol_groups;
  425.     }
  426.     /**
  427.      * @param ProtocolGroup[]|ArrayCollection $protocol_groups
  428.      * @return Company
  429.      */
  430.     public function setProtocolGroups($protocol_groups)
  431.     {
  432.         $this->protocol_groups $protocol_groups;
  433.         return $this;
  434.     }
  435.     /**
  436.      * @return DateTime
  437.      */
  438.     public function getConvertedFromRotex()
  439.     {
  440.         return $this->converted_from_rotex;
  441.     }
  442.     /**
  443.      * @param DateTime $converted_from_rotex
  444.      * @return Company
  445.      */
  446.     public function setConvertedFromRotex(DateTime $converted_from_rotex)
  447.     {
  448.         $this->converted_from_rotex $converted_from_rotex;
  449.         return $this;
  450.     }
  451.     /**
  452.      * @return int
  453.      */
  454.     public function getConvertedFromRotexCompanyId(): int
  455.     {
  456.         return $this->converted_from_rotex_company_id;
  457.     }
  458.     /**
  459.      * @param int $converted_from_rotex_company_id
  460.      * @return Company
  461.      */
  462.     public function setConvertedFromRotexCompanyId(int $converted_from_rotex_company_id): Company
  463.     {
  464.         $this->converted_from_rotex_company_id $converted_from_rotex_company_id;
  465.         return $this;
  466.     }
  467. }