src/V4/Model/Task/Task.php line 298

Open in your IDE?
  1. <?php
  2. namespace App\V4\Model\Task;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiProperty;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. use App\Model\CustomerFile\CustomerFile;
  7. use App\Model\IriNormalizableInterface;
  8. use App\Model\NormalizeAsIRITrait;
  9. use App\Model\SpecificFieldAwareTrait;
  10. use App\Model\SpecificFieldsAwareInterface;
  11. use App\Model\TaskMailingStats\TaskMailingStats;
  12. use App\Model\Traits\BlamableTrait;
  13. use App\Model\Traits\ImportableObjectTrait;
  14. use App\Model\Traits\TimestampableTrait;
  15. use App\V4\Entity\ActionableEntityInterface;
  16. use App\V4\Model\Contact\Contact;
  17. use App\V4\Model\CustomerFileAwareInterface;
  18. use App\V4\Model\Prospect\Prospect;
  19. use App\V4\Model\SpecificField\SpecificField;
  20. use App\V4\Model\TaskQuoteExternalRef\TaskQuoteExternalRef;
  21. use App\V4\Model\TaskSpecificField\TaskSpecificField;
  22. use App\V4\Model\TaskType\TaskType;
  23. use DateTime;
  24. use Doctrine\Common\Collections\ArrayCollection;
  25. use Doctrine\Common\Collections\Collection;
  26. use Symfony\Component\Serializer\Annotation\Groups;
  27. use Symfony\Component\Validator\Constraints as Assert;
  28. /**
  29.  * @ApiResource(
  30.  *     shortName="V4/Task",
  31.  *     attributes={
  32.  *         "api_allow_update": true
  33.  *     },
  34.  *     collectionOperations={
  35.  *         "get": {
  36.  *             "normalization_context": {
  37.  *                  "groups": {"task:list"}
  38.  *             },
  39.  *             "security": "is_granted(constant('App\\V4\\Voters\\TaskVoter::TASK_SHOW_LIST'), 'App\V4\Voters\TaskVoter')"
  40.  *         },
  41.  *         "post_task": {
  42.  *             "method": "POST",
  43.  *             "deserialize": false,
  44.  *             "write": false,
  45.  *             "controller": "App\V4\Controller\Task\TaskDataPersisterAction",
  46.  *             "path": "/V4/tasks",
  47.  *             "input_formats": {
  48.  *                 "multipart": {"multipart/form-data"}
  49.  *             },
  50.  *             "normalization_context": {
  51.  *                  "groups": {"task:read"}
  52.  *             },
  53.  *             "denormalization_context": {
  54.  *                  "groups": {}
  55.  *             }
  56.  *         },
  57.  *         "get_form": {
  58.  *             "method": "GET",
  59.  *             "path": "/V4/tasks/form",
  60.  *             "controller": App\V4\Controller\Task\GetTaskFormAction::class
  61.  *         },
  62.  *         "get_search": {
  63.  *             "method": "GET",
  64.  *             "path": "/V4/tasks/search/form",
  65.  *             "controller": App\V4\Controller\Task\GetTaskSearchFormAction::class,
  66.  *         },
  67.  *         "post_search": {
  68.  *             "method": "POST",
  69.  *             "deserialize": false,
  70.  *             "path": "/V4/tasks/search/form",
  71.  *             "normalization_context": {
  72.  *                  "groups": {"task:list"}
  73.  *             },
  74.  *             "controller": App\V4\Controller\Task\PostTaskSearchFormAction::class,
  75.  *         },
  76.  *         "post_export_request": {
  77.  *             "method": "POST",
  78.  *             "path": "/v4/export/task",
  79.  *             "controller": App\V4\Action\Export\EntityExportRequestAction::class,
  80.  *             "swagger_context": {
  81.  *                 "summary": "Demande de création d'export des actions",
  82.  *                 "description": "Demande de création d'export des actions où 'ids' sont les ids des actions et 'fields' les champs souhaités",
  83.  *                 "parameters": {
  84.  *                     {
  85.  *                         "in": "body",
  86.  *                         "name": "body",
  87.  *                         "schema": {
  88.  *                             "type": "object",
  89.  *                             "properties": {
  90.  *                                 "ids": {
  91.  *                                     "type": "array",
  92.  *                                     "items": {"type": "string"}
  93.  *                                 },
  94.  *                                 "fields": {
  95.  *                                      "type": "array",
  96.  *                                      "items": {"type": "string"}
  97.  *                                 }
  98.  *                             }
  99.  *                         }
  100.  *                     }
  101.  *                 },
  102.  *                 "responses": {
  103.  *                     "201": {
  104.  *                         "description": "Création de l'export avec succès",
  105.  *                         "schema": {
  106.  *                             "type": "object",
  107.  *                             "properties": {
  108.  *                                 "message": {"type": "string", "example": "export_request_created"},
  109.  *                             }
  110.  *                         }
  111.  *                     },
  112.  *                     "400": {
  113.  *                         "description": "Utilisateur non trouvé ou champs 'fields' ou 'ids' manquant dans le body request",
  114.  *                         "schema": {
  115.  *                             "type": "object",
  116.  *                             "properties": {
  117.  *                                 "message": {"type": "string", "example": "user_not_found or missing_fields_or_ids"},
  118.  *                             }
  119.  *                         }
  120.  *                     },
  121.  *                     "422": {
  122.  *                         "description": "Les champs 'fields' ou 'ids' du body request sont vides ou l'entité demandée est invalide",
  123.  *                         "schema": {
  124.  *                             "type": "object",
  125.  *                             "properties": {
  126.  *                                 "message": {"type": "string", "example": "empty_fields_or_ids or entity_not_valid"},
  127.  *                             }
  128.  *                         }
  129.  *                     },
  130.  *                 },
  131.  *             }
  132.  *         },
  133.  *         "post_export_download": {
  134.  *             "method": "POST",
  135.  *             "path": "/v4/export/download/task/{id}",
  136.  *             "controller": App\V4\Action\Export\EntityExportDownloadAction::class,
  137.  *             "swagger_context": {
  138.  *                 "summary": "Demande de téléchargement d'un export actions",
  139.  *                 "description": "Demande de téléchargement d'un export actions ou 'id' est le nom du fichier d'export",
  140.  *                 "requestBody": {},
  141.  *                 "parameters": {
  142.  *                     {
  143.  *                         "in": "path",
  144.  *                         "name": "id",
  145.  *                         "type": "string",
  146.  *                         "required": "true"
  147.  *                     }
  148.  *                 },
  149.  *                 "responses": {
  150.  *                     "200": {
  151.  *                         "description": "Téléchargement de l'export réalisé avec succès"
  152.  *                     },
  153.  *                     "401": {
  154.  *                         "description": "Utilisateur non trouvé ou non connecté",
  155.  *                         "schema": {
  156.  *                             "type": "object",
  157.  *                             "properties": {
  158.  *                                 "message": {"type": "string", "example": "need_authenticated"},
  159.  *                             }
  160.  *                         }
  161.  *                     },
  162.  *                     "404": {
  163.  *                         "description": "Fichier introuvable",
  164.  *                         "schema": {
  165.  *                             "type": "object",
  166.  *                             "properties": {
  167.  *                                 "message": {"type": "string", "example": "export_not_found"},
  168.  *                             }
  169.  *                         }
  170.  *                     },
  171.  *                 },
  172.  *             }
  173.  *         }
  174.  *     },
  175.  *     itemOperations={
  176.  *         "get": {
  177.  *             "path": "/V4/tasks/{id}"
  178.  *         },
  179.  *         "get_form": {
  180.  *             "method": "GET",
  181.  *             "path": "/V4/tasks/{id}/form",
  182.  *             "controller": App\V4\Controller\Task\GetTaskFormAction::class
  183.  *         },
  184.  *         "put_task": {
  185.  *             "method": "POST",
  186.  *             "deserialize": false,
  187.  *             "write": false,
  188.  *             "controller": "App\V4\Controller\Task\TaskDataPersisterAction",
  189.  *             "path": "/V4/tasks/{id}",
  190.  *             "input_formats": {
  191.  *                 "multipart": {"multipart/form-data"}
  192.  *             },
  193.  *             "normalization_context": {
  194.  *                  "groups": {"task:read"}
  195.  *             },
  196.  *             "denormalization_context": {
  197.  *                  "groups": {}
  198.  *             }
  199.  *         },
  200.  *         "renew_task": {
  201.  *             "method": "POST",
  202.  *             "deserialize": false,
  203.  *             "write": false,
  204.  *             "controller": "App\V4\Controller\Task\TaskRenewAction",
  205.  *             "path": "/v4/tasks/renew/{id}",
  206.  *             "swagger_context": {
  207.  *                 "summary": "Renouvèle une action",
  208.  *                 "consumes": {
  209.  *                     "application/json"
  210.  *                 },
  211.  *                 "parameters": {
  212.  *                     {
  213.  *                         "in": "path",
  214.  *                         "name": "id",
  215.  *                         "type": "string",
  216.  *                         "required": true,
  217.  *                     },
  218.  *                     {
  219.  *                         "in": "body",
  220.  *                         "name": "task",
  221.  *                         "schema": {
  222.  *                             "type": "object",
  223.  *                             "properties": {
  224.  *                                 "beginAt": {"type": "string", "example": "2023-06-21T00:00"},
  225.  *                             },
  226.  *                         },
  227.  *                     },
  228.  *                 },
  229.  *             },
  230.  *         },
  231.  *         "close_task": {
  232.  *             "method": "POST",
  233.  *             "deserialize": false,
  234.  *             "write": false,
  235.  *             "controller": "App\V4\Controller\Task\TaskCloseAction",
  236.  *             "path": "/v4/tasks/close/{id}",
  237.  *             "swagger_context": {
  238.  *                 "summary": "Clöture une action",
  239.  *             },
  240.  *         },
  241.  *         "delete_task": {
  242.  *             "method": "DELETE",
  243.  *             "deserialize": false,
  244.  *             "write": false,
  245.  *             "controller": "App\V4\Controller\Task\TaskDataPersisterAction",
  246.  *             "path": "/V4/tasks/{id}"
  247.  *         },
  248.  *         "get_form_move_task": {
  249.  *             "method": "GET",
  250.  *             "path": "/v4/move_task/form",
  251.  *             "controller": "App\V4\Action\Task\MoveTaskAction",
  252.  *             "swagger_context": {
  253.  *                 "summary": "Donne le formulaire de déplacement d'une action",
  254.  *                 "parameters": {},
  255.  *             },
  256.  *         },
  257.  *         "move_task": {
  258.  *             "method": "POST",
  259.  *             "deserialize": false,
  260.  *             "write": false,
  261.  *             "path": "/v4/move_task/{id}",
  262.  *             "controller": "App\V4\Action\Task\MoveTaskAction",
  263.  *             "swagger_context": {
  264.  *                 "summary": "Déplace une action",
  265.  *                 "parameters": {
  266.  *                      {
  267.  *                          "in": "path",
  268.  *                          "name": "id",
  269.  *                          "type": "string",
  270.  *                          "required": true,
  271.  *                      },
  272.  *                      {
  273.  *                          "in": "body",
  274.  *                          "name": "task",
  275.  *                          "schema": {
  276.  *                              "type": "object",
  277.  *                              "properties": {
  278.  *                                  "prospect": {"type": "string", "example": "prospect_id"},
  279.  *                                  "contacts": {
  280.  *                                       "type": "array",
  281.  *                                       "items": {"type": "string"}
  282.  *                                  },
  283.  *                                  "quote": {"type": "string", "example": "quote_id"},
  284.  *                              },
  285.  *                          },
  286.  *                      },
  287.  *                  },
  288.  *             },
  289.  *         },
  290.  *     }
  291.  * )
  292.  *
  293.  * @ApiFilter(App\Filters\PagingFilter::class)
  294.  */
  295. class Task implements IriNormalizableInterfaceSpecificFieldsAwareInterfaceActionableEntityInterfaceCustomerFileAwareInterface
  296. {
  297.     public const SPECIFIC_FIELD_CLASS_NAME TaskSpecificField::class;
  298.     public const DEFAULT_REMINDER_TASK_NAME 'default_reminder_task_name';
  299.     public const MEMO_LINE_TASK_WHEN_QUOTE_STATE_CHANGED 'memo_line_task_when_quote_state_changed';
  300.     public const MEMO_LINE_TASK_WHEN_QUOTE_REMOVED 'memo_line_task_when_quote_removed';
  301.     use TimestampableTrait;
  302.     use BlamableTrait;
  303.     use ImportableObjectTrait;
  304.     use NormalizeAsIRITrait;
  305.     use SpecificFieldAwareTrait;
  306.     /**
  307.      * @ApiProperty(identifier=true)
  308.      *
  309.      * @var string
  310.      *
  311.      * @Groups({
  312.      *     "task:list", "task:read", "task:write", "task:update",
  313.      * })
  314.      */
  315.     private $id;
  316.     /**
  317.      * @var string
  318.      *
  319.      * @Groups({
  320.      *     "task:list", "task:read", "task:write", "task:update",
  321.      * })
  322.      */
  323.     private $forceId;
  324.     /**
  325.      * @Assert\NotNull
  326.      *
  327.      * @var string|null
  328.      *
  329.      * @Groups({
  330.      *     "task:list", "task:read", "task:write", "task:update",
  331.      * })
  332.      */
  333.     private $name;
  334.     /**
  335.      * @var string|null
  336.      *
  337.      * @Groups({
  338.      *     "task:list", "task:read", "task:write", "task:update",
  339.      * })
  340.      */
  341.     private $externalId;
  342.     /**
  343.      * @var string|null
  344.      *
  345.      * @Groups({
  346.      *     "task:list", "task:read", "task:write", "task:update",
  347.      * })
  348.      */
  349.     private $customerId;
  350.     /**
  351.      * @var bool|null
  352.      *
  353.      * @Groups({
  354.      *     "task:list", "task:read", "task:write", "task:update",
  355.      * })
  356.      */
  357.     private $isClosed;
  358.     /**
  359.      * @var DateTime|null
  360.      *
  361.      * @Assert\DateTime(message="field_must_be_date")
  362.      * @Assert\NotBlank()
  363.      *
  364.      * @Groups({
  365.      *     "task:list", "task:read", "task:write", "task:update",
  366.      * })
  367.      */
  368.     private $beginAt;
  369.     /**
  370.      * @var DateTime|null
  371.      *
  372.      * @Assert\DateTime(message="field_must_be_date")
  373.      * @Assert\Blank(groups={"tasktype_is_not_timestamped"}, message="end_date_must_be_empty")
  374.      * @Assert\NotBlank(groups={"tasktype_is_timestamped"}, message="end_date_cannot_be_empty")
  375.      * @Assert\GreaterThanOrEqual(propertyPath="beginAt", groups={"tasktype_is_timestamped"}, message="end_date_must_be_greater")
  376.      *
  377.      * @Groups({
  378.      *     "task:list", "task:read", "task:write", "task:update",
  379.      * })
  380.      */
  381.     private $endAt;
  382.     /**
  383.      * @var string|null
  384.      *
  385.      * @Groups({
  386.      *     "task:list", "task:read", "task:write", "task:update",
  387.      * })
  388.      */
  389.     private $memo;
  390.     /**
  391.      * @var TaskType|null
  392.      * @Assert\NotBlank(
  393.      *     message="Ce champ ne peut pas être vide"
  394.      * )
  395.      *
  396.      * @Groups({
  397.      *     "task:list", "task:read", "task:write", "task:update",
  398.      * })
  399.      */
  400.     private $taskType;
  401.     /**
  402.      * @var TaskMailingStats|null
  403.      *
  404.      * @Groups({
  405.      *     "task:list", "task:read", "task:write", "task:update",
  406.      * })
  407.      */
  408.     private $taskMailingStats;
  409.     /**
  410.      * @var string|null
  411.      *
  412.      * @Groups({
  413.      *     "task:list", "task:read", "task:write", "task:update",
  414.      * })
  415.      */
  416.     private $managedBy;
  417.     /**
  418.      * @var string|null
  419.      *
  420.      * @Groups({
  421.      *     "task:list", "task:read", "task:write", "task:update",
  422.      * })
  423.      */
  424.     private $description;
  425.     /**
  426.      * @var Contact[]|Collection
  427.      *
  428.      * @Groups({
  429.      *     "task:list", "task:read", "task:write", "task:update",
  430.      * })
  431.      */
  432.     private $contacts;
  433.     /**
  434.      * @var Prospect|null
  435.      *
  436.      * @Groups({
  437.      *     "task:list", "task:read", "task:write", "task:update",
  438.      * })
  439.      */
  440.     private $prospect;
  441.     /**
  442.      * @var string|null
  443.      *
  444.      * @Groups({
  445.      *     "task:list", "task:read", "task:write", "task:update",
  446.      * })
  447.      */
  448.     private $managedByRealName;
  449.     /**
  450.      * @var string|null
  451.      *
  452.      * @Groups({
  453.      *     "task:list", "task:read", "task:write", "task:update",
  454.      * })
  455.      */
  456.     private $createdByRealName;
  457.     /**
  458.      * Nom prospect.
  459.      *
  460.      * @var string|null
  461.      *
  462.      * @Groups({
  463.      *     "task:list", "task:read", "task:write", "task:update",
  464.      * })
  465.      */
  466.     private $customerName;
  467.     /**
  468.      * @var string|null
  469.      *
  470.      * @Groups({
  471.      *     "task:list", "task:read", "task:write", "task:update",
  472.      * })
  473.      */
  474.     private $updatedByRealName;
  475.     /**
  476.      * @var string|null
  477.      *
  478.      * @Groups({
  479.      *     "task:list", "task:read", "task:write", "task:update",
  480.      * })
  481.      */
  482.     private $contactsFormatted;
  483.     /**
  484.      * @var string|null
  485.      *
  486.      * @Groups({
  487.      *     "task:list", "task:read", "task:write", "task:update",
  488.      * })
  489.      */
  490.     private $report;
  491.     /**
  492.      * @var CustomerFile[]|Collection
  493.      *
  494.      * @Groups({
  495.      *     "task:list", "task:read", "task:write", "task:update",
  496.      * })
  497.      */
  498.     private $customerFiles;
  499.     /**
  500.      * @var string|null
  501.      *
  502.      * @Groups({
  503.      *     "task:list", "task:read", "task:write", "task:update",
  504.      * })
  505.      */
  506.     private $sectionName;
  507.     /**
  508.      * @var bool|null
  509.      *
  510.      * @Groups({
  511.      *     "task:list", "task:read", "task:write", "task:update",
  512.      * })
  513.      */
  514.     private $isLocked;
  515.     /**
  516.      * @var TaskSpecificField|Collection
  517.      *
  518.      * @Groups({
  519.      *     "task:list", "task:read", "task:write", "task:update",
  520.      * })
  521.      */
  522.     private $specificFields;
  523.     /**
  524.      * @var TaskQuoteExternalRef[]|Collection
  525.      *
  526.      * @Groups({
  527.      *     "task:list", "task:read", "task:write", "task:update",
  528.      * })
  529.      */
  530.     private $quotes;
  531.     /**
  532.      * @var bool
  533.      *
  534.      * @Groups({
  535.      *     "task:list", "task:read", "task:write", "task:update",
  536.      * })
  537.      */
  538.     private $isDraft false;
  539.     public function __construct()
  540.     {
  541.         $this->contacts = new ArrayCollection();
  542.         $this->specificFields = new ArrayCollection();
  543.         $this->quotes = new ArrayCollection();
  544.     }
  545.     /**
  546.      * @return bool
  547.      */
  548.     public function isMailing(): bool
  549.     {
  550.         if (!$this->taskType instanceof TaskType) {
  551.             return false;
  552.         }
  553.         return $this->taskType->isMailing();
  554.     }
  555.     /**
  556.      * @return bool
  557.      */
  558.     public function isSynchroOutlook(): bool
  559.     {
  560.         if (!$this->taskType instanceof TaskType) {
  561.             return false;
  562.         }
  563.         return $this->taskType->isSynchroOutlook();
  564.     }
  565.     /**
  566.      * @return bool
  567.      */
  568.     public function isLate(): bool
  569.     {
  570.         if ($this->isClosed) {
  571.             return false;
  572.         }
  573.         if ($this->endAt instanceof DateTime) {
  574.             return $this->endAt < new DateTime();
  575.         }
  576.         if ($this->beginAt instanceof DateTime) {
  577.             return $this->beginAt < new DateTime();
  578.         }
  579.         return false;
  580.     }
  581.     /**
  582.      * @return bool
  583.      */
  584.     public function isReminder(): bool
  585.     {
  586.         if (!$this->taskType instanceof TaskType) {
  587.             return false;
  588.         }
  589.         return $this->taskType->isReminder();
  590.     }
  591.     /**
  592.      * @return bool
  593.      */
  594.     public function isUnknown(): bool
  595.     {
  596.         return $this->getProspect() instanceof Prospect && $this->getProspect()->isUnknown();
  597.     }
  598.     /**
  599.      * @param string $string
  600.      *
  601.      * @return string|null
  602.      */
  603.     public function getBeginAtWithFormat(string $string): ?string
  604.     {
  605.         return $this->getBeginAt() instanceof DateTime $this->getBeginAt()->format($string) : null;
  606.     }
  607.     public function setQuotesRelationByQuotes(array $quotes)
  608.     {
  609.         $this->quotes = new ArrayCollection();
  610.         foreach ($quotes as $quote) {
  611.             $relation = (new TaskQuoteExternalRef())
  612.                 ->setTask($this)
  613.                 ->setExternalValue($quote->getId())
  614.             ;
  615.             $this->addQuote($relation);
  616.         }
  617.     }
  618.     /**
  619.      * {@inheritdoc}
  620.      */
  621.     public function getSpecificFields(): Collection
  622.     {
  623.         return $this->specificFields;
  624.     }
  625.     /**
  626.      * {@inheritdoc}
  627.      */
  628.     public function getSpecificFieldByFieldId(string $id): ?SpecificField
  629.     {
  630.         foreach ($this->specificFields as $specificField) {
  631.             if ($specificField->getFieldId() === $id) {
  632.                 return $specificField;
  633.             }
  634.         }
  635.         return null;
  636.     }
  637.     /**
  638.      * @see ImportableObjectTrait::class
  639.      *
  640.      * @param TaskSpecificField $specificField
  641.      *
  642.      * @return $this
  643.      */
  644.     public function addTaskSpecificField(TaskSpecificField $specificField): self
  645.     {
  646.         return $this->addSpecificField($specificField);
  647.     }
  648.     /**
  649.      * {@inheritdoc}
  650.      */
  651.     public function addSpecificField($specificField): SpecificFieldsAwareInterface
  652.     {
  653.         $this->specificFields[] = $specificField;
  654.         return $this;
  655.     }
  656.     /**
  657.      * {@inheritdoc}
  658.      */
  659.     public function setSpecificFields(Collection $specificFields): self
  660.     {
  661.         $this->specificFields $specificFields;
  662.         return $this;
  663.     }
  664.     /**
  665.      * @return int
  666.      */
  667.     public function getNbRead(): int
  668.     {
  669.         return $this->getTaskMailingStats() instanceof TaskMailingStats ?
  670.             $this->getTaskMailingStats()->getNbReading() ?? 0;
  671.     }
  672.     /**
  673.      * @return int
  674.      */
  675.     public function getNbClic(): int
  676.     {
  677.         return $this->getTaskMailingStats() instanceof TaskMailingStats ?
  678.             $this->getTaskMailingStats()->getNbClic() ?? 0;
  679.     }
  680.     /**
  681.      * @return string
  682.      */
  683.     public function getId(): ?string
  684.     {
  685.         return $this->id;
  686.     }
  687.     /**
  688.      * @param string|null $id
  689.      *
  690.      * @return Task
  691.      */
  692.     public function setId(?string $id): Task
  693.     {
  694.         $this->id $id;
  695.         return $this;
  696.     }
  697.     /**
  698.      * @return string|null
  699.      */
  700.     public function getName(): ?string
  701.     {
  702.         return $this->name;
  703.     }
  704.     /**
  705.      * @param string|null $name
  706.      *
  707.      * @return Task
  708.      */
  709.     public function setName(?string $name): Task
  710.     {
  711.         $this->name $name;
  712.         return $this;
  713.     }
  714.     /**
  715.      * @return string|null
  716.      */
  717.     public function getExternalId(): ?string
  718.     {
  719.         return $this->externalId;
  720.     }
  721.     /**
  722.      * @param string|null $externalId
  723.      *
  724.      * @return Task
  725.      */
  726.     public function setExternalId(?string $externalId): Task
  727.     {
  728.         $this->externalId $externalId;
  729.         return $this;
  730.     }
  731.     /**
  732.      * @return string|null
  733.      */
  734.     public function getCustomerId(): ?string
  735.     {
  736.         return $this->customerId;
  737.     }
  738.     /**
  739.      * @param string|null $customerId
  740.      *
  741.      * @return Task
  742.      */
  743.     public function setCustomerId(?string $customerId): Task
  744.     {
  745.         $this->customerId $customerId;
  746.         return $this;
  747.     }
  748.     /**
  749.      * @return bool|null
  750.      */
  751.     public function getIsClosed(): ?bool
  752.     {
  753.         return $this->isClosed;
  754.     }
  755.     /**
  756.      * @param bool|null $isClosed
  757.      *
  758.      * @return Task
  759.      */
  760.     public function setIsClosed(?bool $isClosed): Task
  761.     {
  762.         $this->isClosed $isClosed;
  763.         return $this;
  764.     }
  765.     /**
  766.      * @return DateTime|null
  767.      */
  768.     public function getBeginAt(): ?DateTime
  769.     {
  770.         return $this->beginAt;
  771.     }
  772.     /**
  773.      * @param DateTime|null $beginAt
  774.      *
  775.      * @return Task
  776.      */
  777.     public function setBeginAt(?DateTime $beginAt): Task
  778.     {
  779.         $this->beginAt $beginAt;
  780.         return $this;
  781.     }
  782.     /**
  783.      * @return DateTime|null
  784.      */
  785.     public function getEndAt(): ?DateTime
  786.     {
  787.         return $this->endAt;
  788.     }
  789.     /**
  790.      * @param DateTime|null $endAt
  791.      *
  792.      * @return Task
  793.      */
  794.     public function setEndAt(?DateTime $endAt): Task
  795.     {
  796.         $this->endAt $endAt;
  797.         return $this;
  798.     }
  799.     /**
  800.      * @return string|null
  801.      */
  802.     public function getMemo(): ?string
  803.     {
  804.         return $this->memo;
  805.     }
  806.     /**
  807.      * @param string|null $memo
  808.      *
  809.      * @return Task
  810.      */
  811.     public function setMemo(?string $memo): Task
  812.     {
  813.         $this->memo $memo;
  814.         return $this;
  815.     }
  816.     /**
  817.      * @return TaskType|null
  818.      */
  819.     public function getTaskType(): ?TaskType
  820.     {
  821.         return $this->taskType;
  822.     }
  823.     /**
  824.      * @param TaskType|null $taskType
  825.      *
  826.      * @return Task
  827.      */
  828.     public function setTaskType(TaskType $taskType): Task
  829.     {
  830.         $this->taskType $taskType;
  831.         return $this;
  832.     }
  833.     /**
  834.      * @return Contact[]|Collection
  835.      */
  836.     public function getContacts(): Collection
  837.     {
  838.         return $this->contacts;
  839.     }
  840.     /**
  841.      * @param Contact[]|Collection|null $contacts
  842.      *
  843.      * @return Task
  844.      */
  845.     public function setContacts(?Collection $contacts): self
  846.     {
  847.         $this->contacts $contacts;
  848.         return $this;
  849.     }
  850.     /**
  851.      * @param Contact $contact
  852.      *
  853.      * @return Task
  854.      */
  855.     public function addContact(Contact $contact): self
  856.     {
  857.         if (!$this->contacts->contains($contact)) {
  858.             $this->contacts->add($contact);
  859.         }
  860.         return $this;
  861.     }
  862.     /**
  863.      * @param Contact $contact
  864.      *
  865.      * @return Task
  866.      */
  867.     public function removeContact(Contact $contact): self
  868.     {
  869.         if ($this->contacts->contains($contact)) {
  870.             $this->contacts->removeElement($contact);
  871.         }
  872.         return $this;
  873.     }
  874.     /**
  875.      * @param string $contactId
  876.      *
  877.      * @return Task
  878.      */
  879.     public function removeContactById(string $contactId): self
  880.     {
  881.         foreach ($this->getContacts() as $contact) {
  882.             if ($contactId === $contact->getId()) {
  883.                 $this->contacts->removeElement($contact);
  884.                 break;
  885.             }
  886.         }
  887.         return $this;
  888.     }
  889.     /**
  890.      * @return Prospect|null
  891.      */
  892.     public function getProspect(): ?Prospect
  893.     {
  894.         return $this->prospect;
  895.     }
  896.     /**
  897.      * @param Prospect|null $prospect
  898.      *
  899.      * @return $this
  900.      */
  901.     public function setProspect($prospect): self
  902.     {
  903.         $this->prospect $prospect;
  904.         return $this;
  905.     }
  906.     /**
  907.      * @return string|null
  908.      */
  909.     public function getManagedBy(): ?string
  910.     {
  911.         return $this->managedBy;
  912.     }
  913.     /**
  914.      * @param string|null $managedBy
  915.      *
  916.      * @return Task
  917.      */
  918.     public function setManagedBy(?string $managedBy): Task
  919.     {
  920.         $this->managedBy $managedBy;
  921.         return $this;
  922.     }
  923.     /**
  924.      * @return string
  925.      */
  926.     public function getProspectId(): ?string
  927.     {
  928.         return $this->getProspect() ? $this->getProspect()->getId() : null;
  929.     }
  930.     /**
  931.      * @return string|null
  932.      */
  933.     public function getManagedByRealName(): ?string
  934.     {
  935.         return $this->managedByRealName;
  936.     }
  937.     /**
  938.      * @param string|null $managedByRealName
  939.      *
  940.      * @return $this
  941.      */
  942.     public function setManagedByRealName(?string $managedByRealName): self
  943.     {
  944.         $this->managedByRealName $managedByRealName;
  945.         return $this;
  946.     }
  947.     /**
  948.      * @return string|null
  949.      */
  950.     public function getDescription(): ?string
  951.     {
  952.         return $this->description;
  953.     }
  954.     /**
  955.      * @param string|null $description
  956.      *
  957.      * @return Task
  958.      */
  959.     public function setDescription(?string $description): Task
  960.     {
  961.         $this->description $description;
  962.         return $this;
  963.     }
  964.     /**
  965.      * @Groups({"list", "read", "list_task", "read_task", "list_prospect", "read_prospect",  "read_post_task", "write_post_task"})
  966.      *
  967.      * @return string|null
  968.      */
  969.     public function getCreatedBy(): ?string
  970.     {
  971.         return $this->createdBy;
  972.     }
  973.     /**
  974.      * @Groups({"list", "read", "list_task", "read_task", "list_prospect", "read_prospect",  "read_post_task", "write_post_task"})
  975.      *
  976.      * @return string|null
  977.      */
  978.     public function getUpdatedBy(): ?string
  979.     {
  980.         return $this->updatedBy;
  981.     }
  982.     /**
  983.      * @Groups({"list", "read", "list_task", "read_task", "list_prospect", "read_prospect",  "read_post_task", "write_post_task"})
  984.      *
  985.      * @return DateTime|null
  986.      */
  987.     public function getCreatedAt(): ?DateTime
  988.     {
  989.         return $this->createdAt;
  990.     }
  991.     /**
  992.      * @Groups({"list", "read", "list_task", "read_task", "list_prospect", "read_prospect",  "read_post_task", "write_post_task"})
  993.      *
  994.      * @return DateTime|null
  995.      */
  996.     public function getUpdatedAt(): ?DateTime
  997.     {
  998.         return $this->updatedAt;
  999.     }
  1000.     /**
  1001.      * @return string|null
  1002.      */
  1003.     public function getCreatedByRealName(): ?string
  1004.     {
  1005.         return $this->createdByRealName;
  1006.     }
  1007.     /**
  1008.      * @param string|null $createdByRealName
  1009.      *
  1010.      * @return Task
  1011.      */
  1012.     public function setCreatedByRealName(?string $createdByRealName): Task
  1013.     {
  1014.         $this->createdByRealName $createdByRealName;
  1015.         return $this;
  1016.     }
  1017.     /**
  1018.      * @return string|null
  1019.      */
  1020.     public function getUpdatedByRealName(): ?string
  1021.     {
  1022.         return $this->updatedByRealName;
  1023.     }
  1024.     /**
  1025.      * @param string|null $updatedByRealName
  1026.      *
  1027.      * @return Task
  1028.      */
  1029.     public function setUpdatedByRealName(?string $updatedByRealName): Task
  1030.     {
  1031.         $this->updatedByRealName $updatedByRealName;
  1032.         return $this;
  1033.     }
  1034.     /**
  1035.      * @return string|null
  1036.      */
  1037.     public function getReport(): ?string
  1038.     {
  1039.         return $this->report;
  1040.     }
  1041.     /**
  1042.      * @param string|null $report
  1043.      *
  1044.      * @return Task
  1045.      */
  1046.     public function setReport(?string $report): Task
  1047.     {
  1048.         $this->report $report;
  1049.         return $this;
  1050.     }
  1051.     /**
  1052.      * @return CustomerFile[]
  1053.      */
  1054.     public function getCustomerFiles()
  1055.     {
  1056.         return $this->customerFiles;
  1057.     }
  1058.     /**
  1059.      * @param CustomerFile $customerFile
  1060.      *
  1061.      * @return Task
  1062.      */
  1063.     public function addCustomerFile(CustomerFile $customerFile): self
  1064.     {
  1065.         $this->customerFiles[] = $customerFile;
  1066.         return $this;
  1067.     }
  1068.     /**
  1069.      * @param CustomerFile $customerFile
  1070.      *
  1071.      * @return Task
  1072.      */
  1073.     public function removeCustomerFile(CustomerFile $customerFile): self
  1074.     {
  1075.         $index array_search($customerFile$this->customerFilestrue);
  1076.         if (false !== $index) {
  1077.             unset($this->customerFiles[$index]);
  1078.         }
  1079.         return $this;
  1080.     }
  1081.     /**
  1082.      * @param CustomerFile[] $customerFiles
  1083.      *
  1084.      * @return Task
  1085.      */
  1086.     public function setCustomerFiles(array $customerFiles): self
  1087.     {
  1088.         $this->customerFiles $customerFiles;
  1089.         return $this;
  1090.     }
  1091.     /**
  1092.      * @return string|null
  1093.      */
  1094.     public function getForceId(): ?string
  1095.     {
  1096.         return $this->forceId $this->forceId null;
  1097.     }
  1098.     /**
  1099.      * @param string|null $forceId
  1100.      *
  1101.      * @return Task
  1102.      */
  1103.     public function setForceId(?string $forceId): Task
  1104.     {
  1105.         $this->forceId $forceId;
  1106.         return $this;
  1107.     }
  1108.     /**
  1109.      * @return TaskMailingStats|null
  1110.      */
  1111.     public function getTaskMailingStats(): ?TaskMailingStats
  1112.     {
  1113.         return $this->taskMailingStats;
  1114.     }
  1115.     /**
  1116.      * @param TaskMailingStats|null $taskMailingStats
  1117.      *
  1118.      * @return Task
  1119.      */
  1120.     public function setTaskMailingStats(?TaskMailingStats $taskMailingStats): Task
  1121.     {
  1122.         $this->taskMailingStats $taskMailingStats;
  1123.         return $this;
  1124.     }
  1125.     /**
  1126.      * @return string|null
  1127.      */
  1128.     public function getContactsFormatted(): ?string
  1129.     {
  1130.         return $this->contactsFormatted;
  1131.     }
  1132.     /**
  1133.      * @param string|null $contactsFormatted
  1134.      *
  1135.      * @return Task
  1136.      */
  1137.     public function setContactsFormatted(?string $contactsFormatted): Task
  1138.     {
  1139.         $this->contactsFormatted $contactsFormatted;
  1140.         return $this;
  1141.     }
  1142.     /**
  1143.      * @return string|null
  1144.      */
  1145.     public function getCustomerName(): ?string
  1146.     {
  1147.         return $this->customerName;
  1148.     }
  1149.     /**
  1150.      * @param string|null $customerName
  1151.      *
  1152.      * @return Task
  1153.      */
  1154.     public function setCustomerName(?string $customerName): Task
  1155.     {
  1156.         $this->customerName $customerName;
  1157.         return $this;
  1158.     }
  1159.     /**
  1160.      * @return string|null
  1161.      */
  1162.     public function getSectionName(): ?string
  1163.     {
  1164.         return $this->sectionName;
  1165.     }
  1166.     /**
  1167.      * @param string|null $sectionName
  1168.      *
  1169.      * @return Task
  1170.      */
  1171.     public function setSectionName(?string $sectionName): Task
  1172.     {
  1173.         $this->sectionName $sectionName;
  1174.         return $this;
  1175.     }
  1176.     /**
  1177.      * @return bool|null
  1178.      */
  1179.     public function isLocked(): ?bool
  1180.     {
  1181.         return $this->isLocked;
  1182.     }
  1183.     /**
  1184.      * @todo PV-942 : indispensable pour api platform
  1185.      *
  1186.      * @return bool|null
  1187.      */
  1188.     public function getIsLocked(): ?bool
  1189.     {
  1190.         return $this->isLocked();
  1191.     }
  1192.     /**
  1193.      * @param bool|null $isLocked
  1194.      *
  1195.      * @return Task
  1196.      */
  1197.     public function setIsLocked(?bool $isLocked): self
  1198.     {
  1199.         $this->isLocked $isLocked;
  1200.         return $this;
  1201.     }
  1202.     /**
  1203.      * @param string $quoteId
  1204.      *
  1205.      * @return bool
  1206.      */
  1207.     public function hasQuote(string $quoteId): bool
  1208.     {
  1209.         foreach ($this->quotes as $quote) {
  1210.             if ($quoteId === $quote->getExternalValue()) {
  1211.                 return true;
  1212.             }
  1213.         }
  1214.         return false;
  1215.     }
  1216.     /**
  1217.      * @return TaskQuoteExternalRef[]|Collection
  1218.      */
  1219.     public function getQuotes(): Collection
  1220.     {
  1221.         return $this->quotes;
  1222.     }
  1223.     /**
  1224.      * @param TaskQuoteExternalRef[]|Collection $quotes
  1225.      *
  1226.      * @return self
  1227.      */
  1228.     public function setQuotes(Collection $quotes): self
  1229.     {
  1230.         $this->quotes $quotes;
  1231.         return $this;
  1232.     }
  1233.     /**
  1234.      * @param TaskQuoteExternalRef $quote
  1235.      *
  1236.      * @return self
  1237.      */
  1238.     public function addQuote(TaskQuoteExternalRef $quote): self
  1239.     {
  1240.         if (!$this->quotes->contains($quote)) {
  1241.             $this->quotes->add($quote);
  1242.         }
  1243.         return $this;
  1244.     }
  1245.     /**
  1246.      * Redondance avec addQuote dû au ImportableObjectTrait.
  1247.      *
  1248.      * @param TaskQuoteExternalRef $quote
  1249.      *
  1250.      * @return self
  1251.      */
  1252.     public function addTaskQuoteExternalRef(TaskQuoteExternalRef $quote): self
  1253.     {
  1254.         return $this->addQuote($quote);
  1255.     }
  1256.     /**
  1257.      * @param TaskQuoteExternalRef $quote
  1258.      *
  1259.      * @return self
  1260.      */
  1261.     public function removeQuote(TaskQuoteExternalRef $quote): self
  1262.     {
  1263.         if ($this->quotes->contains($quote)) {
  1264.             $this->quotes->remove($quote);
  1265.         }
  1266.         return $this;
  1267.     }
  1268.     public function removeTaskQuoteExternalRefByExternalValue(?string $quoteId)
  1269.     {
  1270.         foreach ($this->quotes as $quote) {
  1271.             if ($quoteId === $quote->getExternalValue()) {
  1272.                 $this->removeQuote($quote);
  1273.             }
  1274.         }
  1275.     }
  1276.     public function getIsDraft(): bool
  1277.     {
  1278.         return $this->isDraft;
  1279.     }
  1280.     public function setIsDraft(bool $isDraft): self
  1281.     {
  1282.         $this->isDraft $isDraft;
  1283.         return $this;
  1284.     }
  1285. }