1 | <?php |
||
67 | class Opportunity extends ExtendOpportunity implements |
||
68 | EmailHolderInterface, |
||
69 | ChannelAwareInterface |
||
70 | { |
||
71 | use ChannelEntityTrait; |
||
72 | |||
73 | const INTERNAL_STATUS_CODE = 'opportunity_status'; |
||
74 | |||
75 | /** |
||
76 | * The key in system config for probability - status map |
||
77 | */ |
||
78 | const PROBABILITIES_CONFIG_KEY = 'oro_crm_sales.default_opportunity_probabilities'; |
||
79 | |||
80 | /** |
||
81 | * @var int |
||
82 | * |
||
83 | * @ORM\Id |
||
84 | * @ORM\Column(type="integer", name="id") |
||
85 | * @ORM\GeneratedValue(strategy="AUTO") |
||
86 | * @ConfigField( |
||
87 | * defaultValues={ |
||
88 | * "importexport"={ |
||
89 | * "order"=0 |
||
90 | * } |
||
91 | * } |
||
92 | * ) |
||
93 | */ |
||
94 | protected $id; |
||
95 | |||
96 | /** |
||
97 | * @var OpportunityCloseReason |
||
98 | * |
||
99 | * @ORM\ManyToOne(targetEntity="OroCRM\Bundle\SalesBundle\Entity\OpportunityCloseReason") |
||
100 | * @ORM\JoinColumn(name="close_reason_name", referencedColumnName="name") |
||
101 | * @Oro\Versioned |
||
102 | * @ConfigField( |
||
103 | * defaultValues={ |
||
104 | * "dataaudit"={"auditable"=true}, |
||
105 | * "importexport"={ |
||
106 | * "order"=100, |
||
107 | * "short"=true |
||
108 | * } |
||
109 | * } |
||
110 | * ) |
||
111 | **/ |
||
112 | protected $closeReason; |
||
113 | |||
114 | /** |
||
115 | * @var Contact |
||
116 | * |
||
117 | * @ORM\ManyToOne(targetEntity="OroCRM\Bundle\ContactBundle\Entity\Contact", cascade={"persist"}) |
||
118 | * @ORM\JoinColumn(name="contact_id", referencedColumnName="id", onDelete="SET NULL") |
||
119 | * @Oro\Versioned |
||
120 | * @ConfigField( |
||
121 | * defaultValues={ |
||
122 | * "dataaudit"={"auditable"=true}, |
||
123 | * "importexport"={ |
||
124 | * "order"=120, |
||
125 | * "short"=true |
||
126 | * }, |
||
127 | * "form"={ |
||
128 | * "form_type"="orocrm_contact_select" |
||
129 | * } |
||
130 | * } |
||
131 | * ) |
||
132 | **/ |
||
133 | protected $contact; |
||
134 | |||
135 | /** |
||
136 | * @var Lead |
||
137 | * |
||
138 | * @ORM\ManyToOne(targetEntity="OroCRM\Bundle\SalesBundle\Entity\Lead", inversedBy="opportunities") |
||
139 | * @ORM\JoinColumn(name="lead_id", referencedColumnName="id", onDelete="SET NULL") |
||
140 | * @Oro\Versioned |
||
141 | * @ConfigField( |
||
142 | * defaultValues={ |
||
143 | * "dataaudit"={"auditable"=true}, |
||
144 | * "importexport"={ |
||
145 | * "order"=130, |
||
146 | * "short"=true |
||
147 | * } |
||
148 | * } |
||
149 | * ) |
||
150 | **/ |
||
151 | protected $lead; |
||
152 | |||
153 | /** |
||
154 | * @var User |
||
155 | * @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User") |
||
156 | * @ORM\JoinColumn(name="user_owner_id", referencedColumnName="id", onDelete="SET NULL") |
||
157 | * @Oro\Versioned |
||
158 | * @ConfigField( |
||
159 | * defaultValues={ |
||
160 | * "dataaudit"={"auditable"=true}, |
||
161 | * "importexport"={ |
||
162 | * "order"=140, |
||
163 | * "short"=true |
||
164 | * } |
||
165 | * } |
||
166 | * ) |
||
167 | */ |
||
168 | protected $owner; |
||
169 | |||
170 | /** |
||
171 | * @var string |
||
172 | * |
||
173 | * @ORM\Column(name="name", type="string", length=255, nullable=false) |
||
174 | * @Oro\Versioned |
||
175 | * @ConfigField( |
||
176 | * defaultValues={ |
||
177 | * "dataaudit"={"auditable"=true}, |
||
178 | * "importexport"={ |
||
179 | * "order"=10, |
||
180 | * "identity"=true |
||
181 | * } |
||
182 | * } |
||
183 | * ) |
||
184 | */ |
||
185 | protected $name; |
||
186 | |||
187 | /** |
||
188 | * @var \DateTime |
||
189 | * |
||
190 | * @ORM\Column(name="close_date", type="date", nullable=true) |
||
191 | * @Oro\Versioned |
||
192 | * @ConfigField( |
||
193 | * defaultValues={ |
||
194 | * "dataaudit"={"auditable"=true}, |
||
195 | * "importexport"={ |
||
196 | * "order"=20 |
||
197 | * } |
||
198 | * } |
||
199 | * ) |
||
200 | */ |
||
201 | protected $closeDate; |
||
202 | |||
203 | /** |
||
204 | * @var float |
||
205 | * |
||
206 | * @ORM\Column(name="probability", type="percent", nullable=true) |
||
207 | * @Oro\Versioned |
||
208 | * @ConfigField( |
||
209 | * defaultValues={ |
||
210 | * "form"={ |
||
211 | * "form_type"="oro_percent", |
||
212 | * "form_options"={ |
||
213 | * "constraints"={{"Range":{"min":0, "max":100}}}, |
||
214 | * } |
||
215 | * }, |
||
216 | * "dataaudit"={ |
||
217 | * "auditable"=true |
||
218 | * }, |
||
219 | * "importexport"={ |
||
220 | * "order"=30 |
||
221 | * } |
||
222 | * } |
||
223 | * ) |
||
224 | */ |
||
225 | protected $probability; |
||
226 | |||
227 | /** |
||
228 | * @var double |
||
229 | * |
||
230 | * @ORM\Column(name="budget_amount", type="money", nullable=true) |
||
231 | * @Oro\Versioned |
||
232 | * @ConfigField( |
||
233 | * defaultValues={ |
||
234 | * "form"={ |
||
235 | * "form_type"="oro_money", |
||
236 | * "form_options"={ |
||
237 | * "constraints"={{"Range":{"min":0}}}, |
||
238 | * } |
||
239 | * }, |
||
240 | * "dataaudit"={ |
||
241 | * "auditable"=true |
||
242 | * }, |
||
243 | * "importexport"={ |
||
244 | * "order"=40 |
||
245 | * } |
||
246 | * } |
||
247 | * ) |
||
248 | */ |
||
249 | protected $budgetAmount; |
||
250 | |||
251 | /** |
||
252 | * @var double |
||
253 | * |
||
254 | * @ORM\Column(name="close_revenue", type="money", nullable=true) |
||
255 | * @Oro\Versioned |
||
256 | * @ConfigField( |
||
257 | * defaultValues={ |
||
258 | * "form"={ |
||
259 | * "form_type"="oro_money", |
||
260 | * "form_options"={ |
||
261 | * "constraints"={{"Range":{"min":0}}}, |
||
262 | * } |
||
263 | * }, |
||
264 | * "dataaudit"={ |
||
265 | * "auditable"=true |
||
266 | * }, |
||
267 | * "importexport"={ |
||
268 | * "order"=50 |
||
269 | * } |
||
270 | * } |
||
271 | * ) |
||
272 | */ |
||
273 | protected $closeRevenue; |
||
274 | |||
275 | /** |
||
276 | * @var string |
||
277 | * |
||
278 | * @ORM\Column(name="customer_need", type="text", nullable=true) |
||
279 | * @Oro\Versioned |
||
280 | * @ConfigField( |
||
281 | * defaultValues={ |
||
282 | * "dataaudit"={"auditable"=true}, |
||
283 | * "importexport"={ |
||
284 | * "order"=60 |
||
285 | * } |
||
286 | * } |
||
287 | * ) |
||
288 | */ |
||
289 | protected $customerNeed; |
||
290 | |||
291 | /** |
||
292 | * @var string |
||
293 | * |
||
294 | * @ORM\Column(name="proposed_solution", type="text", nullable=true) |
||
295 | * @Oro\Versioned |
||
296 | * @ConfigField( |
||
297 | * defaultValues={ |
||
298 | * "dataaudit"={"auditable"=true}, |
||
299 | * "importexport"={ |
||
300 | * "order"=70 |
||
301 | * } |
||
302 | * } |
||
303 | * ) |
||
304 | */ |
||
305 | protected $proposedSolution; |
||
306 | |||
307 | /** |
||
308 | * @var \DateTime |
||
309 | * |
||
310 | * @ORM\Column(name="created_at", type="datetime") |
||
311 | * @ConfigField( |
||
312 | * defaultValues={ |
||
313 | * "entity"={ |
||
314 | * "label"="oro.ui.created_at" |
||
315 | * }, |
||
316 | * "importexport"={ |
||
317 | * "excluded"=true |
||
318 | * } |
||
319 | * } |
||
320 | * ) |
||
321 | */ |
||
322 | protected $createdAt; |
||
323 | |||
324 | /** |
||
325 | * @var \DateTime |
||
326 | * |
||
327 | * @ORM\Column(name="updated_at", type="datetime") |
||
328 | * @ConfigField( |
||
329 | * defaultValues={ |
||
330 | * "entity"={ |
||
331 | * "label"="oro.ui.updated_at" |
||
332 | * }, |
||
333 | * "importexport"={ |
||
334 | * "excluded"=true |
||
335 | * } |
||
336 | * } |
||
337 | * ) |
||
338 | */ |
||
339 | protected $updatedAt; |
||
340 | |||
341 | /** |
||
342 | * @var string |
||
343 | * |
||
344 | * @ORM\Column(name="notes", type="text", nullable=true) |
||
345 | * @Oro\Versioned |
||
346 | * @ConfigField( |
||
347 | * defaultValues={ |
||
348 | * "dataaudit"={ |
||
349 | * "auditable"=true |
||
350 | * }, |
||
351 | * "importexport"={ |
||
352 | * "order"=80 |
||
353 | * } |
||
354 | * } |
||
355 | * ) |
||
356 | */ |
||
357 | protected $notes; |
||
358 | |||
359 | /** |
||
360 | * @var Organization |
||
361 | * |
||
362 | * @ORM\ManyToOne(targetEntity="Oro\Bundle\OrganizationBundle\Entity\Organization") |
||
363 | * @ORM\JoinColumn(name="organization_id", referencedColumnName="id", onDelete="SET NULL") |
||
364 | */ |
||
365 | protected $organization; |
||
366 | |||
367 | /** |
||
368 | * @var B2bCustomer |
||
369 | * |
||
370 | * @ORM\ManyToOne( |
||
371 | * targetEntity="OroCRM\Bundle\SalesBundle\Entity\B2bCustomer", |
||
372 | * inversedBy="opportunities", |
||
373 | * cascade={"persist"} |
||
374 | * ) |
||
375 | * @ORM\JoinColumn(name="customer_id", referencedColumnName="id", onDelete="SET NULL") |
||
376 | * @Oro\Versioned |
||
377 | * @ConfigField( |
||
378 | * defaultValues={ |
||
379 | * "dataaudit"={"auditable"=true}, |
||
380 | * "importexport"={ |
||
381 | * "order"=110, |
||
382 | * "short"=true |
||
383 | * }, |
||
384 | * "form"={ |
||
385 | * "form_type"="orocrm_sales_b2bcustomer_select" |
||
386 | * } |
||
387 | * } |
||
388 | * ) |
||
389 | */ |
||
390 | protected $customer; |
||
391 | |||
392 | /** |
||
393 | * @return int |
||
394 | */ |
||
395 | public function getId() |
||
399 | |||
400 | /** |
||
401 | * @param Lead $lead |
||
402 | * @return Opportunity |
||
403 | */ |
||
404 | public function setLead($lead) |
||
410 | |||
411 | /** |
||
412 | * @return Lead |
||
413 | */ |
||
414 | public function getLead() |
||
418 | |||
419 | /** |
||
420 | * @param float $budgetAmount |
||
421 | * @return Opportunity |
||
422 | */ |
||
423 | public function setBudgetAmount($budgetAmount) |
||
429 | |||
430 | /** |
||
431 | * @return float |
||
432 | */ |
||
433 | public function getBudgetAmount() |
||
437 | |||
438 | /** |
||
439 | * @param \DateTime $closeDate |
||
440 | * @return Opportunity |
||
441 | */ |
||
442 | public function setCloseDate($closeDate) |
||
448 | |||
449 | /** |
||
450 | * @return \DateTime |
||
451 | */ |
||
452 | public function getCloseDate() |
||
456 | |||
457 | /** |
||
458 | * @param Contact $contact |
||
459 | * @return Opportunity |
||
460 | */ |
||
461 | public function setContact($contact) |
||
467 | |||
468 | /** |
||
469 | * @return Contact |
||
470 | */ |
||
471 | public function getContact() |
||
475 | |||
476 | /** |
||
477 | * @param string $customerNeed |
||
478 | * @return Opportunity |
||
479 | */ |
||
480 | public function setCustomerNeed($customerNeed) |
||
486 | |||
487 | /** |
||
488 | * @return string |
||
489 | */ |
||
490 | public function getCustomerNeed() |
||
494 | |||
495 | /** |
||
496 | * @param float $probability |
||
497 | * @return Opportunity |
||
498 | */ |
||
499 | public function setProbability($probability) |
||
505 | |||
506 | /** |
||
507 | * @return float |
||
508 | */ |
||
509 | public function getProbability() |
||
513 | |||
514 | /** |
||
515 | * @param string $proposedSolution |
||
516 | * @return Opportunity |
||
517 | */ |
||
518 | public function setProposedSolution($proposedSolution) |
||
524 | |||
525 | /** |
||
526 | * @return string |
||
527 | */ |
||
528 | public function getProposedSolution() |
||
532 | |||
533 | /** |
||
534 | * @param string $name |
||
535 | * @return Opportunity |
||
536 | */ |
||
537 | public function setName($name) |
||
543 | |||
544 | /** |
||
545 | * @return string |
||
546 | */ |
||
547 | public function getName() |
||
551 | |||
552 | /** |
||
553 | * @param OpportunityCloseReason $closeReason |
||
554 | * @return Opportunity |
||
555 | */ |
||
556 | public function setCloseReason($closeReason) |
||
562 | |||
563 | /** |
||
564 | * @return OpportunityCloseReason |
||
565 | */ |
||
566 | public function getCloseReason() |
||
570 | |||
571 | /** |
||
572 | * @param float $revenue |
||
573 | */ |
||
574 | public function setCloseRevenue($revenue) |
||
578 | |||
579 | /** |
||
580 | * @return float |
||
581 | */ |
||
582 | public function getCloseRevenue() |
||
586 | |||
587 | /** |
||
588 | * @return \DateTime |
||
589 | */ |
||
590 | public function getCreatedAt() |
||
594 | |||
595 | /** |
||
596 | * @param \DateTime $created |
||
597 | * @return Opportunity |
||
598 | */ |
||
599 | public function setCreatedAt($created) |
||
605 | |||
606 | /** |
||
607 | * @return \DateTime |
||
608 | */ |
||
609 | public function getUpdatedAt() |
||
613 | |||
614 | /** |
||
615 | * @param \DateTime $updated |
||
616 | * @return Opportunity |
||
617 | */ |
||
618 | public function setUpdatedAt($updated) |
||
624 | |||
625 | /** |
||
626 | * Get the primary email address of the related contact |
||
627 | * |
||
628 | * @return string |
||
629 | */ |
||
630 | public function getEmail() |
||
639 | |||
640 | public function __toString() |
||
644 | /** |
||
645 | * @ORM\PrePersist |
||
646 | */ |
||
647 | public function beforeSave() |
||
652 | |||
653 | /** |
||
654 | * @ORM\PreUpdate |
||
655 | */ |
||
656 | public function beforeUpdate() |
||
660 | |||
661 | /** |
||
662 | * @return User |
||
663 | */ |
||
664 | public function getOwner() |
||
668 | |||
669 | /** |
||
670 | * @param User $owningUser |
||
671 | * @return Opportunity |
||
672 | */ |
||
673 | public function setOwner($owningUser) |
||
679 | |||
680 | /** |
||
681 | * @return string |
||
682 | */ |
||
683 | public function getNotes() |
||
687 | |||
688 | /** |
||
689 | * @param string $notes |
||
690 | * @return Opportunity |
||
691 | */ |
||
692 | public function setNotes($notes) |
||
698 | |||
699 | /** |
||
700 | * @param B2bCustomer $customer |
||
701 | * @TODO remove null after BAP-5248 |
||
702 | */ |
||
703 | public function setCustomer(B2bCustomer $customer = null) |
||
707 | |||
708 | /** |
||
709 | * @return B2bCustomer |
||
710 | */ |
||
711 | public function getCustomer() |
||
715 | |||
716 | /** |
||
717 | * Set organization |
||
718 | * |
||
719 | * @param Organization $organization |
||
720 | * @return Opportunity |
||
721 | */ |
||
722 | public function setOrganization(Organization $organization = null) |
||
728 | |||
729 | /** |
||
730 | * Get organization |
||
731 | * |
||
732 | * @return Organization |
||
733 | */ |
||
734 | public function getOrganization() |
||
738 | |||
739 | /** |
||
740 | * Remove Customer |
||
741 | * |
||
742 | * @return Lead |
||
743 | */ |
||
744 | public function removeCustomer() |
||
748 | } |
||
749 |