src/Entity/Supplier.php line 37

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Validator\Constraints as AppAssert;
  4. use App\Classes\Hasher;
  5. use App\Entity\Product\Product;
  6. use App\Model\ProtectedInterface;
  7. use Cocur\Slugify\Slugify;
  8. use DateTime;
  9. use DateTimeImmutable;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Exception;
  13. use Gedmo\Mapping\Annotation as Gedmo;
  14. use JMS\Serializer\Annotation as Serializer;
  15. use JMS\Serializer\Annotation\ExclusionPolicy;
  16. use JMS\Serializer\Annotation\Expose;
  17. use Symfony\Component\Security\Core\User\UserInterface;
  18. use Symfony\Component\Validator\Constraints as Assert;
  19. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  20. /**
  21.  * Class Supplier
  22.  *
  23.  * @ORM\Entity(repositoryClass="App\Repository\SupplierRepository")
  24.  * @ORM\Table(name="malys_supplier")
  25.  * @ORM\HasLifecycleCallbacks()
  26.  * @ExclusionPolicy("all")
  27.  * @Vich\Uploadable
  28.  * @AppAssert\Supplier(groups={"all"})
  29.  * @Serializer\VirtualProperty(
  30.  *     "emailAddress",
  31.  *     exp="object.getEmailAddress() ? object.getEmailAddress().getAddress() : null"
  32.  * )
  33.  */
  34. class Supplier implements UserInterfaceProtectedInterface
  35. {
  36.     public const SUGGEST_ARGS_MAX_SIZE 300;
  37.     public const SHORT_DELIVERY_AREA_MAX_SIZE 45;
  38.     public const STATUS_UNTRUSTED "untrusted";
  39.     public const STATUS_TRUSTED "trusted";
  40.     public const STATUS_PARTNER "partner";
  41.     public const STATUSES = [
  42.         'Guest à confirmer' => self::STATUS_UNTRUSTED,
  43.         'Guest confirmé'    => self::STATUS_TRUSTED,
  44.         'Partenaire'        => self::STATUS_PARTNER
  45.     ];
  46.     /**
  47.      * @var integer
  48.      *
  49.      * @ORM\Column(name="id", type="integer")
  50.      * @ORM\Id
  51.      * @ORM\GeneratedValue(strategy="AUTO")
  52.      * @Expose
  53.      */
  54.     protected $id;
  55.     /**
  56.      * @var string
  57.      *
  58.      * @ORM\Column(name="company_name", type="string", length=255, nullable=false)
  59.      * @Expose
  60.      * @Assert\NotBlank(message="Veuillez indiquer le nom du fournisseur")
  61.      */
  62.     protected $companyName;
  63.     /**
  64.      * @var string
  65.      *
  66.      * @ORM\Column(name="short_company_name", type="string", length=255, nullable=true)
  67.      * @Expose
  68.      */
  69.     protected $shortCompanyName;
  70.     /**
  71.      * @var string
  72.      *
  73.      * @ORM\Column(name="logo", type="string", nullable=true)
  74.      */
  75.     protected $picture;
  76.     /**
  77.      * Not persisted
  78.      * @Vich\UploadableField(mapping="supplier_picture", fileNameProperty="picture")
  79.      */
  80.     private $pictureFile;
  81.     /**
  82.      * @var EmailAddress
  83.      *
  84.      * Serialized as virtual property (address property)
  85.      *
  86.      * @ORM\ManyToOne(targetEntity="EmailAddress", cascade={"persist"})
  87.      * @ORM\JoinColumn(name="email_address_id", referencedColumnName="id")
  88.      * @Assert\Valid(groups={"Default"})
  89.      */
  90.     protected $emailAddress;
  91.     /**
  92.      * @var string
  93.      *
  94.      * @ORM\Column(name="apikey", type="string", nullable=true)
  95.      */
  96.     protected $apikey;
  97.     /**
  98.      * @var string
  99.      *
  100.      * @ORM\Column(name="account_opening_time", type="string", length=255, nullable=true)
  101.      */
  102.     protected $accountOpeningTime;
  103.     /**
  104.      * @var string
  105.      *
  106.      * @ORM\Column(name="address", type="string", nullable=true)
  107.      * @Expose
  108.      */
  109.     protected $address;
  110.     /**
  111.      * @var string
  112.      *
  113.      * @ORM\Column(name="zip_code", type="string", nullable=true)
  114.      * @Expose
  115.      */
  116.     protected $zipCode;
  117.     /**
  118.      * @var string
  119.      *
  120.      * @ORM\Column(name="city", type="string", nullable=true)
  121.      * @Expose
  122.      */
  123.     protected $city;
  124.     /**
  125.      * @var string
  126.      *
  127.      * @ORM\Column(name="country", type="string", nullable=true)
  128.      * @Expose
  129.      */
  130.     protected $country;
  131.     /**
  132.      * @var string
  133.      *
  134.      * @ORM\Column(name="short_description", type="text", nullable=true)
  135.      * @Expose
  136.      */
  137.     protected $shortDescription;
  138.     /**
  139.      * @var string
  140.      *
  141.      * @ORM\Column(name="comment", type="text", nullable=true)
  142.      */
  143.     protected $comment;
  144.     /**
  145.      * @var float
  146.      * @ORM\Column(name="minimum_tax_excluded", type="float", nullable=true)
  147.      * @Assert\NotBlank(groups={"api"})
  148.      * @Expose
  149.      */
  150.     protected $minimumTaxExcluded;
  151.     /**
  152.      * @var ArrayCollection
  153.      *
  154.      * @ORM\OneToMany(targetEntity="DeliveryModel", mappedBy="supplier", cascade={"remove", "persist"})
  155.      */
  156.     protected $deliveriesModel;
  157.     /**
  158.      * @var string
  159.      *
  160.      * @ORM\Column(name="phone", type="string", nullable=true)
  161.      * @Expose
  162.      */
  163.     protected $phone;
  164.     /**
  165.      * @var string
  166.      *
  167.      * @ORM\Column(name="mobile", type="string", nullable=true)
  168.      * @Expose
  169.      */
  170.     protected $mobile;
  171.     /**
  172.      * @var ArrayCollection
  173.      *
  174.      * @ORM\OneToMany(targetEntity="SupplierContact", mappedBy="supplier", cascade={"remove"})
  175.      */
  176.     protected $contacts;
  177.     /**
  178.      * @var boolean
  179.      *
  180.      * @ORM\Column(name="enabled", type="boolean", options={"default" : true})
  181.      * @Expose
  182.      */
  183.     protected $enabled true;
  184.     /**
  185.      * @var boolean
  186.      *
  187.      * @ORM\Column(name="orders_enabled", type="boolean", options={"default" : true})
  188.      * @Expose
  189.      */
  190.     protected $ordersEnabled true;
  191.     /**
  192.      * @var string
  193.      *
  194.      * @ORM\Column(name="orders_comment", type="text", nullable=true)
  195.      * @Expose
  196.      */
  197.     protected $ordersComment;
  198.     /**
  199.      * @var ArrayCollection
  200.      *
  201.      * @ORM\OneToMany(targetEntity="App\Entity\Product\Product", mappedBy="supplier", cascade={"remove"})
  202.      */
  203.     protected $products;
  204.     /**
  205.      * @var boolean
  206.      *
  207.      * @ORM\Column(name="primeur", type="boolean", options={"default" : false}, nullable=true)
  208.      * @Expose
  209.      */
  210.     protected $primeur false;
  211.     /**
  212.      * @var string
  213.      *
  214.      * @ORM\Column(name="website", type="string", nullable=true)
  215.      * @Expose
  216.      */
  217.     protected $website;
  218.     /**
  219.      * @var ArrayCollection
  220.      *
  221.      * @ORM\OneToMany(targetEntity="SupplierCustomer", mappedBy="supplier", cascade={"remove"})
  222.      */
  223.     protected $customers;
  224.     /**
  225.      * @var mixed
  226.      *
  227.      * @ORM\OneToMany(targetEntity="SupplierCustomerNoTP", mappedBy="supplier", cascade={"remove"})
  228.      */
  229.     protected $noTPCustomers;
  230.     /**
  231.      * @var ArrayCollection
  232.      *
  233.      * @ORM\OneToMany(targetEntity="SupplierProductService", mappedBy="supplier", cascade={"all"}, orphanRemoval=true)
  234.      */
  235.     protected $productServices;
  236.     /**
  237.      * @var boolean
  238.      */
  239.     protected $associatedToCustomer false;
  240.     /**
  241.      * @var DateTime
  242.      *
  243.      * @ORM\Column(name="createdAt", type="datetime", nullable=false)
  244.      */
  245.     protected $createdAt;
  246.     /**
  247.      * @var DateTime
  248.      *
  249.      * @ORM\Column(name="updatedAt", type="datetime", nullable=true)
  250.      */
  251.     protected $updatedAt;
  252.     /**
  253.      * @Gedmo\Slug(fields={"companyName"})
  254.      * @ORM\Column(length=128, unique=true)
  255.      */
  256.     protected $slug;
  257.     /**
  258.      * @var string
  259.      *
  260.      * @ORM\Column(name="cgu_file", type="string", nullable=true)
  261.      */
  262.     protected $cguFile;
  263.     /**
  264.      * @var string
  265.      *
  266.      * @ORM\Column(name="suggest_arg1", type="text", nullable=true)
  267.      * @Assert\Length(max=Supplier::SUGGEST_ARGS_MAX_SIZE, groups={"all", "api"})
  268.      * @Expose
  269.      */
  270.     protected $suggestArgumentOne;
  271.     /**
  272.      * @var string
  273.      *
  274.      * @ORM\Column(name="suggest_arg2", type="text", nullable=true)
  275.      * @Assert\Length(max=Supplier::SUGGEST_ARGS_MAX_SIZE, groups={"all", "api"})
  276.      * @Expose
  277.      */
  278.     protected $suggestArgumentTwo;
  279.     /**
  280.      * @var string
  281.      *
  282.      * @ORM\Column(name="suggest_arg3", type="text", nullable=true)
  283.      * @Assert\Length(max=Supplier::SUGGEST_ARGS_MAX_SIZE, groups={"all", "api"})
  284.      * @Expose
  285.      */
  286.     protected $suggestArgumentThree;
  287.     /**
  288.      * @var string
  289.      *
  290.      * @ORM\Column(name="suggest_arg4", type="text", nullable=true)
  291.      * @Assert\Length(max=Supplier::SUGGEST_ARGS_MAX_SIZE, groups={"all", "api"})
  292.      * @Expose
  293.      */
  294.     protected $suggestArgumentFour;
  295.     /**
  296.      * @var array
  297.      *
  298.      * @ORM\Column(name="working_days", type="simple_array", nullable=true)
  299.      * @Expose
  300.      */
  301.     protected $workingDays;
  302.     /**
  303.      * @var string
  304.      *
  305.      * @ORM\Column(name="status", type="string", length=255, nullable=false, options={"default"=App\Entity\Supplier::STATUS_UNTRUSTED})
  306.      * @Assert\Choice(choices=Supplier::STATUSES, message="The status you chose is forbidden", groups={"all", "api"})
  307.      * @Expose
  308.      */
  309.     protected $status self::STATUS_UNTRUSTED;
  310.     /**
  311.      * @var string
  312.      *
  313.      * @ORM\Column(name="color", type="string", length=255, nullable=true)
  314.      */
  315.     protected $color;
  316.     /**
  317.      * @ORM\ManyToMany(targetEntity="App\Entity\Customer", mappedBy="suggestedSuppliers")
  318.      */
  319.     protected $suggestedForCustomers;
  320.     /**
  321.      * @ORM\Column(name="product_families", type="string", length=255, nullable=true)
  322.      * @Expose
  323.      */
  324.     protected $productFamilies;
  325.     /**
  326.      * @ORM\Column(name="precise_delivery_area", type="string", length=255, nullable=true)
  327.      */
  328.     protected $preciseDeliveryArea;
  329.     /**
  330.      * @ORM\Column(name="short_delivery_area", type="string", length=255, nullable=true)
  331.      * @Expose
  332.      */
  333.     protected $shortDeliveryArea;
  334.     /**
  335.      * @var ArrayCollection
  336.      *
  337.      * @ORM\OneToMany(targetEntity="Webhook", mappedBy="supplier", cascade={"remove"})
  338.      */
  339.     protected $webhooks;
  340.     /**
  341.      * @ORM\Column(name="hashed_id", type="string", nullable=false)
  342.      */
  343.     protected $hashedId;
  344.     /**
  345.      * @ORM\OneToMany(targetEntity="App\Entity\Invoice", mappedBy="supplier")
  346.      */
  347.     protected $invoices;
  348.     /**
  349.      * @ORM\OneToMany(targetEntity="App\Entity\SupplierHoliday", mappedBy="supplier")
  350.      */
  351.     protected $holidays;
  352.     /**
  353.      * @ORM\Column(name="receive_products_from_interface", type="boolean", options={"default" : false})
  354.      */
  355.     protected $receiveProductsFromInterface false;
  356.     /**
  357.      * @ORM\Column(name="send_orders_to_interface", type="boolean", options={"default" : false})
  358.      */
  359.     protected $sendOrdersToInterface false;
  360.     /**
  361.      * @ORM\Column(name="send_orders_by_email", type="boolean", options={"default" : true})
  362.      */
  363.     protected $sendOrdersByEmail true;
  364.     /**
  365.      * Supplier constructor.
  366.      */
  367.     public function __construct()
  368.     {
  369.         $this->contacts              = new ArrayCollection();
  370.         $this->deliveriesModel       = new ArrayCollection();
  371.         $this->products              = new ArrayCollection();
  372.         $this->customers             = new ArrayCollection();
  373.         $this->productServices       = new ArrayCollection();
  374.         $this->suggestedForCustomers = new ArrayCollection();
  375.         $this->webhooks              = new ArrayCollection();
  376.         $this->invoices                 = new ArrayCollection();
  377.     }
  378.     public function __toString()
  379.     {
  380.         return $this->companyName;
  381.     }
  382.     /**
  383.      * @ORM\PrePersist
  384.      */
  385.     public function prePersist()
  386.     {
  387.         if ($this->companyName == null) {
  388.             $this->companyName 'Nouveau fournisseur';
  389.         }
  390.     }
  391.     /**
  392.      * @return int
  393.      */
  394.     public function getId()
  395.     {
  396.         return $this->id;
  397.     }
  398.     /**
  399.      * @param int $id
  400.      */
  401.     public function setId($id)
  402.     {
  403.         $this->id $id;
  404.     }
  405.     /**
  406.      * @return string
  407.      */
  408.     public function getCompanyName()
  409.     {
  410.         return $this->companyName;
  411.     }
  412.     /**
  413.      * @param string $companyName
  414.      *
  415.      */
  416.     public function setCompanyName($companyName)
  417.     {
  418.         $this->companyName $companyName;
  419.     }
  420.     /**
  421.      * @return string
  422.      */
  423.     public function getPicture()
  424.     {
  425.         return $this->picture;
  426.     }
  427.     /**
  428.      * @param string $picture
  429.      */
  430.     public function setPicture($picture)
  431.     {
  432.         $this->picture $picture;
  433.     }
  434.     public function setPictureFile($pictureFile null)
  435.     {
  436.         $this->pictureFile $pictureFile;
  437.         if (null !== $pictureFile) {
  438.             $this->updatedAt = new DateTimeImmutable();
  439.         }
  440.     }
  441.     public function getPictureFile()
  442.     {
  443.         return $this->pictureFile;
  444.     }
  445.     /**
  446.      * @return EmailAddress|null
  447.      */
  448.     public function getEmailAddress(): ?EmailAddress
  449.     {
  450.         return $this->emailAddress;
  451.     }
  452.     /**
  453.      * @param EmailAddress|null $emailAddress
  454.      */
  455.     public function setEmailAddress(?EmailAddress $emailAddress)
  456.     {
  457.         $this->emailAddress $emailAddress;
  458.     }
  459.     /**
  460.      * @return string
  461.      */
  462.     public function getAccountOpeningTime()
  463.     {
  464.         return $this->accountOpeningTime;
  465.     }
  466.     /**
  467.      * @param string $accountOpeningTime
  468.      */
  469.     public function setAccountOpeningTime($accountOpeningTime)
  470.     {
  471.         $this->accountOpeningTime $accountOpeningTime;
  472.     }
  473.     /**
  474.      * @return string
  475.      */
  476.     public function getAddress()
  477.     {
  478.         return $this->address;
  479.     }
  480.     /**
  481.      * @param string $address
  482.      */
  483.     public function setAddress($address)
  484.     {
  485.         $this->address $address;
  486.     }
  487.     /**
  488.      * @return string
  489.      */
  490.     public function getZipCode()
  491.     {
  492.         return $this->zipCode;
  493.     }
  494.     /**
  495.      * @param string $zipCode
  496.      */
  497.     public function setZipCode($zipCode)
  498.     {
  499.         $this->zipCode $zipCode;
  500.     }
  501.     /**
  502.      * @return string
  503.      */
  504.     public function getCity()
  505.     {
  506.         return $this->city;
  507.     }
  508.     /**
  509.      * @param string $city
  510.      */
  511.     public function setCity($city)
  512.     {
  513.         $this->city $city;
  514.     }
  515.     /**
  516.      * @return string
  517.      */
  518.     public function getCountry()
  519.     {
  520.         return $this->country;
  521.     }
  522.     /**
  523.      * @param string $country
  524.      */
  525.     public function setCountry($country)
  526.     {
  527.         $this->country $country;
  528.     }
  529.     /**
  530.      * @return string
  531.      */
  532.     public function getShortDescription()
  533.     {
  534.         return $this->shortDescription;
  535.     }
  536.     /**
  537.      * @param string $shortDescription
  538.      */
  539.     public function setShortDescription($shortDescription)
  540.     {
  541.         $this->shortDescription $shortDescription;
  542.     }
  543.     /**
  544.      * @return string
  545.      */
  546.     public function getComment()
  547.     {
  548.         return $this->comment;
  549.     }
  550.     /**
  551.      * @param string $comment
  552.      */
  553.     public function setComment($comment)
  554.     {
  555.         $this->comment $comment;
  556.     }
  557.     /**
  558.      * @return float
  559.      */
  560.     public function getMinimumTaxExcluded()
  561.     {
  562.         return $this->minimumTaxExcluded;
  563.     }
  564.     /**
  565.      * @param float $minimumTaxExcluded
  566.      */
  567.     public function setMinimumTaxExcluded($minimumTaxExcluded)
  568.     {
  569.         $this->minimumTaxExcluded $minimumTaxExcluded;
  570.     }
  571.     /**
  572.      * @return string
  573.      */
  574.     public function getPhone()
  575.     {
  576.         return $this->phone;
  577.     }
  578.     /**
  579.      * @param string $phone
  580.      */
  581.     public function setPhone($phone)
  582.     {
  583.         $this->phone $phone;
  584.     }
  585.     /**
  586.      * @return string
  587.      */
  588.     public function getMobile()
  589.     {
  590.         return $this->mobile;
  591.     }
  592.     /**
  593.      * @param string $mobile
  594.      */
  595.     public function setMobile($mobile)
  596.     {
  597.         $this->mobile $mobile;
  598.     }
  599.     /**
  600.      * @return ArrayCollection
  601.      */
  602.     public function getContacts()
  603.     {
  604.         return $this->contacts;
  605.     }
  606.     /**
  607.      * @param ArrayCollection $contacts
  608.      */
  609.     public function setContacts($contacts)
  610.     {
  611.         $this->contacts $contacts;
  612.     }
  613.     /**
  614.      * @param SupplierContact $contact
  615.      */
  616.     public function addContact($contact)
  617.     {
  618.         $this->contacts->add($contact);
  619.     }
  620.     /**
  621.      * @param SupplierContact $contact
  622.      */
  623.     public function removeContact($contact)
  624.     {
  625.         if ($this->contacts->contains($contact)) {
  626.             $this->contacts->removeElement($contact);
  627.         }
  628.     }
  629.     /**
  630.      * @return ArrayCollection
  631.      */
  632.     public function getDeliveriesModel()
  633.     {
  634.         return $this->deliveriesModel;
  635.     }
  636.     /**
  637.      * @param ArrayCollection $deliveriesModel
  638.      */
  639.     public function setDeliveriesModel($deliveriesModel)
  640.     {
  641.         $this->deliveriesModel $deliveriesModel;
  642.     }
  643.     /**
  644.      * @param DeliveryModel $deliveryModel
  645.      */
  646.     public function addDeliveryModel(DeliveryModel $deliveryModel)
  647.     {
  648.         $this->deliveriesModel->add($deliveryModel);
  649.     }
  650.     /**
  651.      * @param DeliveryModel $deliveryModel
  652.      */
  653.     public function removeDeliveryModel(DeliveryModel $deliveryModel)
  654.     {
  655.         if ($this->deliveriesModel->contains($deliveryModel)) {
  656.             $this->deliveriesModel->removeElement($deliveryModel);
  657.         }
  658.     }
  659.     /**
  660.      * @return bool
  661.      */
  662.     public function isPrimeur()
  663.     {
  664.         return $this->primeur;
  665.     }
  666.     /**
  667.      * @param bool $primeur
  668.      */
  669.     public function setPrimeur($primeur)
  670.     {
  671.         $this->primeur $primeur;
  672.     }
  673.     /**
  674.      * @return string
  675.      */
  676.     public function getWebsite()
  677.     {
  678.         return $this->website;
  679.     }
  680.     /**
  681.      * @param string $website
  682.      */
  683.     public function setWebsite($website)
  684.     {
  685.         $this->website $website;
  686.     }
  687.     /**
  688.      * @return mixed
  689.      */
  690.     public function getProducts()
  691.     {
  692.         return $this->products;
  693.     }
  694.     /**
  695.      * @param mixed $products
  696.      */
  697.     public function setProducts($products)
  698.     {
  699.         $this->products $products;
  700.     }
  701.     /**
  702.      * @param Product $product
  703.      */
  704.     public function addProduct($product)
  705.     {
  706.         $this->products->add($product);
  707.     }
  708.     /**
  709.      * @param Product $product
  710.      */
  711.     public function removeProduct($product)
  712.     {
  713.         if ($this->products->contains($product)) {
  714.             $this->products->removeElement($product);
  715.         }
  716.     }
  717.     /**
  718.      * @return bool
  719.      */
  720.     public function isEnabled()
  721.     {
  722.         return $this->enabled;
  723.     }
  724.     /**
  725.      * @param bool $enabled
  726.      */
  727.     public function setEnabled($enabled)
  728.     {
  729.         $this->enabled $enabled;
  730.     }
  731.     /**
  732.      * @return ArrayCollection
  733.      */
  734.     public function getCustomers()
  735.     {
  736.         return $this->customers;
  737.     }
  738.     /**
  739.      * @param ArrayCollection $customers
  740.      */
  741.     public function setCustomers($customers)
  742.     {
  743.         $this->customers $customers;
  744.     }
  745.     /**
  746.      * @return bool
  747.      */
  748.     public function isAssociatedToCustomer()
  749.     {
  750.         return $this->associatedToCustomer;
  751.     }
  752.     /**
  753.      * @param bool $associatedToCustomer
  754.      */
  755.     public function setAssociatedToCustomer($associatedToCustomer)
  756.     {
  757.         $this->associatedToCustomer $associatedToCustomer;
  758.     }
  759.     /**
  760.      * @return DateTime
  761.      */
  762.     public function getCreatedAt()
  763.     {
  764.         return $this->createdAt;
  765.     }
  766.     /**
  767.      * Set createdAt
  768.      *
  769.      * @return Supplier
  770.      * @ORM\PrePersist
  771.      * @throws Exception
  772.      */
  773.     public function setCreatedAt()
  774.     {
  775.         $this->createdAt = new DateTime();
  776.         $this->updatedAt = new DateTime();
  777.         return $this;
  778.     }
  779.     /**
  780.      * @return DateTime
  781.      */
  782.     public function getUpdatedAt()
  783.     {
  784.         return $this->updatedAt;
  785.     }
  786.     /**
  787.      * Set updatedAt
  788.      *
  789.      * @return Supplier
  790.      * @ORM\PreUpdate
  791.      * @throws Exception
  792.      */
  793.     public function setUpdatedAt()
  794.     {
  795.         $this->updatedAt = new DateTime();
  796.         return $this;
  797.     }
  798.     /**
  799.      * @return string
  800.      */
  801.     public function getFirstContactPhone()
  802.     {
  803.         $firstContactPhone 'Non renseigné';
  804.         if (! empty($this->getContacts()) && isset($this->getContacts()[0])) {
  805.             $firstContactPhone $this->getContacts()[0]->getMobile();
  806.         }
  807.         return $firstContactPhone;
  808.     }
  809.     /**
  810.      * @return string
  811.      */
  812.     public function getFirstContactEmail()
  813.     {
  814.         $firstContactEmail 'Non renseigné';
  815.         if (! empty($this->getContacts()) && isset($this->getContacts()[0])) {
  816.             $firstContactEmail $this->getContacts()[0]->getEmail();
  817.         }
  818.         return $firstContactEmail;
  819.     }
  820.     /**
  821.      * @return string
  822.      */
  823.     public function getDirectoryName()
  824.     {
  825.         $slugify = new Slugify();
  826.         return $this->getId() . '_' $slugify->slugify($this->getCompanyName());
  827.     }
  828.     /**
  829.      * @return mixed
  830.      */
  831.     public function getSlug()
  832.     {
  833.         return $this->slug;
  834.     }
  835.     /**
  836.      * @param mixed $slug
  837.      */
  838.     public function setSlug($slug)
  839.     {
  840.         $this->slug $slug;
  841.     }
  842.     /**
  843.      * @return string
  844.      */
  845.     public function getCguFile()
  846.     {
  847.         return $this->cguFile;
  848.     }
  849.     /**
  850.      * @param string $cguFile
  851.      */
  852.     public function setCguFile($cguFile)
  853.     {
  854.         $this->cguFile $cguFile;
  855.     }
  856.     /**
  857.      * @return ArrayCollection
  858.      */
  859.     public function getProductServices()
  860.     {
  861.         return $this->productServices;
  862.     }
  863.     /**
  864.      * @param ArrayCollection $productServices
  865.      */
  866.     public function setProductServices($productServices)
  867.     {
  868.         $this->productServices $productServices;
  869.     }
  870.     public function addProductService($productService)
  871.     {
  872.         $productService->setSupplier($this);
  873.         $this->productServices->add($productService);
  874.     }
  875.     public function removeProductService($productService)
  876.     {
  877.         if ($this->productServices->contains($productService)) {
  878.             $this->productServices->removeElement($productService);
  879.         }
  880.     }
  881.     /**
  882.      * @return string
  883.      */
  884.     public function getShortCompanyName()
  885.     {
  886.         return $this->shortCompanyName;
  887.     }
  888.     /**
  889.      * @param string $shortCompanyName
  890.      */
  891.     public function setShortCompanyName($shortCompanyName)
  892.     {
  893.         $this->shortCompanyName $shortCompanyName;
  894.     }
  895.     /**
  896.      * @return string
  897.      */
  898.     public function getSuggestArgumentOne()
  899.     {
  900.         return $this->suggestArgumentOne;
  901.     }
  902.     /**
  903.      * @param string $suggestArgumentOne
  904.      */
  905.     public function setSuggestArgumentOne($suggestArgumentOne)
  906.     {
  907.         $this->suggestArgumentOne $suggestArgumentOne;
  908.     }
  909.     /**
  910.      * @return string
  911.      */
  912.     public function getSuggestArgumentTwo()
  913.     {
  914.         return $this->suggestArgumentTwo;
  915.     }
  916.     /**
  917.      * @param string $suggestArgumentTwo
  918.      */
  919.     public function setSuggestArgumentTwo($suggestArgumentTwo)
  920.     {
  921.         $this->suggestArgumentTwo $suggestArgumentTwo;
  922.     }
  923.     /**
  924.      * @return string
  925.      */
  926.     public function getSuggestArgumentThree()
  927.     {
  928.         return $this->suggestArgumentThree;
  929.     }
  930.     /**
  931.      * @param string $suggestArgumentThree
  932.      */
  933.     public function setSuggestArgumentThree($suggestArgumentThree)
  934.     {
  935.         $this->suggestArgumentThree $suggestArgumentThree;
  936.     }
  937.     /**
  938.      * @return string
  939.      */
  940.     public function getSuggestArgumentFour()
  941.     {
  942.         return $this->suggestArgumentFour;
  943.     }
  944.     /**
  945.      * @param string $suggestArgumentFour
  946.      */
  947.     public function setSuggestArgumentFour($suggestArgumentFour)
  948.     {
  949.         $this->suggestArgumentFour $suggestArgumentFour;
  950.     }
  951.     /**
  952.      * @return array
  953.      */
  954.     public function getWorkingDays()
  955.     {
  956.         return $this->workingDays;
  957.     }
  958.     /**
  959.      * @param array $workingDays
  960.      */
  961.     public function setWorkingDays($workingDays)
  962.     {
  963.         $this->workingDays $workingDays;
  964.     }
  965.     /**
  966.      * @return string
  967.      */
  968.     public function getStatus()
  969.     {
  970.         return $this->status;
  971.     }
  972.     /**
  973.      * @param $status
  974.      */
  975.     public function setStatus($status)
  976.     {
  977.         $this->status $status;
  978.     }
  979.     /**
  980.      * @return string
  981.      */
  982.     public function getColor()
  983.     {
  984.         return $this->color;
  985.     }
  986.     /**
  987.      * @param string $color
  988.      */
  989.     public function setColor($color)
  990.     {
  991.         $this->color $color;
  992.     }
  993.     /**
  994.      * @return bool
  995.      */
  996.     public function isOrdersEnabled(): bool
  997.     {
  998.         return $this->ordersEnabled;
  999.     }
  1000.     /**
  1001.      * @param bool $ordersEnabled
  1002.      */
  1003.     public function setOrdersEnabled(bool $ordersEnabled)
  1004.     {
  1005.         $this->ordersEnabled $ordersEnabled;
  1006.     }
  1007.     /**
  1008.      * @return string
  1009.      */
  1010.     public function getOrdersComment(): ?string
  1011.     {
  1012.         return $this->ordersComment;
  1013.     }
  1014.     /**
  1015.      * @param string $ordersComment
  1016.      */
  1017.     public function setOrdersComment(?string $ordersComment)
  1018.     {
  1019.         $this->ordersComment $ordersComment;
  1020.     }
  1021.     /**
  1022.      * @return ArrayCollection|Customer[]
  1023.      */
  1024.     public function getSuggestedForCustomers()
  1025.     {
  1026.         return $this->suggestedForCustomers;
  1027.     }
  1028.     /**
  1029.      * @param mixed $suggestedForCustomers
  1030.      */
  1031.     public function setSuggestedSuppliers($suggestedForCustomers)
  1032.     {
  1033.         $this->suggestedForCustomers $suggestedForCustomers;
  1034.     }
  1035.     /**
  1036.      * @return string|null
  1037.      */
  1038.     public function getProductFamilies(): ?string
  1039.     {
  1040.         return $this->productFamilies;
  1041.     }
  1042.     /**
  1043.      * @param string $productFamilies
  1044.      */
  1045.     public function setProductFamilies(?string $productFamilies)
  1046.     {
  1047.         $this->productFamilies $productFamilies;
  1048.     }
  1049.     /**
  1050.      * @return string|null
  1051.      */
  1052.     public function getPreciseDeliveryArea()
  1053.     {
  1054.         return $this->preciseDeliveryArea;
  1055.     }
  1056.     /**
  1057.      * @param string $preciseDeliveryArea
  1058.      */
  1059.     public function setPreciseDeliveryArea($preciseDeliveryArea)
  1060.     {
  1061.         $this->preciseDeliveryArea $preciseDeliveryArea;
  1062.     }
  1063.     /**
  1064.      * @return mixed
  1065.      */
  1066.     public function getShortDeliveryArea()
  1067.     {
  1068.         return $this->shortDeliveryArea;
  1069.     }
  1070.     /**
  1071.      * @param mixed $shortDeliveryArea
  1072.      */
  1073.     public function setShortDeliveryArea($shortDeliveryArea): void
  1074.     {
  1075.         $this->shortDeliveryArea $shortDeliveryArea;
  1076.     }
  1077.     /**
  1078.      * @param string|null $hashedId
  1079.      *
  1080.      * @return Supplier
  1081.      */
  1082.     public function setHashedId(?string $hashedId): Supplier
  1083.     {
  1084.         $this->hashedId $hashedId;
  1085.         return $this;
  1086.     }
  1087.     /**
  1088.      * @return string|null
  1089.      */
  1090.     public function getHashedId(): ?string
  1091.     {
  1092.         return $this->hashedId;
  1093.     }
  1094.     /**
  1095.      * @ORM\PrePersist
  1096.      */
  1097.     public function installHashedId()
  1098.     {
  1099.         if (is_null($this->hashedId)) {
  1100.             $this->hashedId Hasher::generateHash(self::class);
  1101.         }
  1102.     }
  1103.     public function getRoles(): array
  1104.     {
  1105.         return [ 'ROLE_USER''ROLE_SUPPIER' ];
  1106.     }
  1107.     public function getPassword():?string
  1108.     {
  1109.     }
  1110.     public function getSalt():?string
  1111.     {
  1112.     }
  1113.     // Used for API
  1114.     public function getUsername(): string
  1115.     {
  1116.         return $this->getHashedId();
  1117.     }
  1118.     public function eraseCredentials()
  1119.     {
  1120.     }
  1121.     /**
  1122.      * @return ArrayCollection
  1123.      */
  1124.     public function getWebhooks()
  1125.     {
  1126.         return $this->webhooks;
  1127.     }
  1128.     /**
  1129.      * @param ArrayCollection $webhooks
  1130.      */
  1131.     public function setWebhooks($webhooks)
  1132.     {
  1133.         $this->webhooks $webhooks;
  1134.     }
  1135.     /**
  1136.      * @param Webhook $webhook
  1137.      */
  1138.     public function addWebhook($webhook)
  1139.     {
  1140.         $this->webhooks->add($webhook);
  1141.     }
  1142.     /**
  1143.      * @param Webhook $webhook
  1144.      */
  1145.     public function removeWebhook($webhook)
  1146.     {
  1147.         if ($this->webhooks->contains($webhook)) {
  1148.             $this->webhooks->removeElement($webhook);
  1149.         }
  1150.     }
  1151.     /**
  1152.      * @return string
  1153.      */
  1154.     public function getApikey(): string
  1155.     {
  1156.         return $this->apikey;
  1157.     }
  1158.     /**
  1159.      * @param string $apikey
  1160.      */
  1161.     public function setApikey(string $apikey): void
  1162.     {
  1163.         $this->apikey $apikey;
  1164.     }
  1165.     /**
  1166.      * @return mixed
  1167.      */
  1168.     public function getHolidays()
  1169.     {
  1170.         return $this->holidays;
  1171.     }
  1172.     /**
  1173.      * @return ArrayCollection
  1174.      */
  1175.     public function getInvoices()
  1176.     {
  1177.         return $this->invoices;
  1178.     }
  1179.     /**
  1180.      * @return mixed
  1181.      */
  1182.     public function getNoTPCustomers()
  1183.     {
  1184.         return $this->noTPCustomers;
  1185.     }
  1186.     /**
  1187.      * @param mixed $noTPCustomers
  1188.      */
  1189.     public function setNoTPCustomers($noTPCustomers): void
  1190.     {
  1191.         $this->noTPCustomers $noTPCustomers;
  1192.     }
  1193.     /**
  1194.      * @return bool
  1195.      */
  1196.     public function isReceiveProductsFromInterface(): bool
  1197.     {
  1198.         return $this->receiveProductsFromInterface;
  1199.     }
  1200.     /**
  1201.      * @param bool $receiveProductsFromInterface
  1202.      */
  1203.     public function setReceiveProductsFromInterface(bool $receiveProductsFromInterface): void
  1204.     {
  1205.         $this->receiveProductsFromInterface $receiveProductsFromInterface;
  1206.     }
  1207.     /**
  1208.      * @return bool
  1209.      */
  1210.     public function isSendOrdersToInterface(): bool
  1211.     {
  1212.         return $this->sendOrdersToInterface;
  1213.     }
  1214.     /**
  1215.      * @param bool $sendOrdersToInterface
  1216.      */
  1217.     public function setSendOrdersToInterface(bool $sendOrdersToInterface): void
  1218.     {
  1219.         $this->sendOrdersToInterface $sendOrdersToInterface;
  1220.     }
  1221.     /**
  1222.      * @return bool
  1223.      */
  1224.     public function isSendOrdersByEmail(): bool
  1225.     {
  1226.         return $this->sendOrdersByEmail;
  1227.     }
  1228.     /**
  1229.      * @param bool $sendOrdersByEmail
  1230.      */
  1231.     public function setSendOrdersByEmail(bool $sendOrdersByEmail): void
  1232.     {
  1233.         $this->sendOrdersByEmail $sendOrdersByEmail;
  1234.     }
  1235.     public function isDeletable(): bool
  1236.     {
  1237.         return in_array($this->getStatus(), [
  1238.             self::STATUS_UNTRUSTED,
  1239.             self::STATUS_TRUSTED
  1240.         ]);
  1241.     }
  1242. }