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

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