/** * @param string $key * @param Opportunity $entity */ public function fillEntityData($key, $entity) { $userRepo = $this->templateManager->getEntityRepository('Oro\\Bundle\\UserBundle\\Entity\\User'); $customerRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\SalesBundle\\Entity\\B2bCustomer'); $contactRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\ContactBundle\\Entity\\Contact'); $leadRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\SalesBundle\\Entity\\Lead'); $channelRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\ChannelBundle\\Entity\\Channel'); $organizationRepo = $this->templateManager->getEntityRepository('Oro\\Bundle\\OrganizationBundle\\Entity\\Organization'); switch ($key) { case 'Jerry Coleman': $entity->setName('Oro Inc. Opportunity Name'); $entity->setCustomer($customerRepo->getEntity('Jerry Coleman')); $entity->setDataChannel($channelRepo->getEntity('B2b channel|b2b')); $entity->setCreatedAt(new \DateTime()); $entity->setUpdatedAt(new \DateTime()); $entity->setOwner($userRepo->getEntity('John Doo')); $entity->setOrganization($organizationRepo->getEntity('default')); $entity->setBudgetAmount(1000000); $entity->setContact($contactRepo->getEntity('Jerry Coleman')); $entity->setLead($leadRepo->getEntity('Jerry Coleman')); $entity->setStatus(new OpportunityStatus('In Progress')); return; } parent::fillEntityData($key, $entity); }
/** * @param Contact $contact * @param B2bCustomer $customer * @param User $user * * @return Opportunity */ protected function createOpportunity($contact, $customer, $user) { $opportunity = new Opportunity(); $dataChannel = $this->getReference('default_channel'); $opportunity->setName($contact->getFirstName() . ' ' . $contact->getLastName()); $opportunity->setContact($contact); $opportunity->setOwner($user); $opportunity->setOrganization($this->organization); $opportunity->setCustomer($customer); $opportunity->setDataChannel($dataChannel); return $opportunity; }
protected function createOpportunity() { $opportunity = new Opportunity(); $opportunity->setName('opname'); $opportunity->setCustomer($this->getReference('default_b2bcustomer')); $opportunity->setDataChannel($this->getReference('default_channel')); $opportunity->setBudgetAmount(50.0); $opportunity->setProbability(10); $opportunity->setOrganization($this->organization); $this->em->persist($opportunity); $this->em->flush(); $this->setReference('default_opportunity', $opportunity); return $this; }
/** * Create opportunity form with data channel * * @Route("/create/{channelIds}", name="orocrm_sales_opportunity_data_channel_aware_create") * @Template("OroCRMSalesBundle:Opportunity:update.html.twig") * @AclAncestor("orocrm_sales_opportunity_create") * * @ParamConverter( * "channel", * class="OroCRMChannelBundle:Channel", * options={"id" = "channelIds"} * ) */ public function opportunityWithDataChannelCreateAction(Channel $channel) { $opportunity = new Opportunity(); $opportunity->setDataChannel($channel); return $this->update($opportunity); }
/** * @depends testRemoveOpportunityFromB2bCustomer * * Test that no processing occured for b2bcustomers that were deleted * assert that onFlush event listeners not throwing exceptions */ public function testRemovedB2bCustomer() { $em = $this->getEntityManager(); $organization = $em->getRepository('OroOrganizationBundle:Organization')->getFirst(); $opportunity = new Opportunity(); $opportunity->setName('remove_b2bcustomer_test'); $opportunity->setDataChannel($this->getReference('default_channel')); $opportunity->setCloseRevenue(50); $opportunity->setBudgetAmount(50.0); $opportunity->setProbability(10); $opportunity->setStatus($em->getReference('OroCRMSalesBundle:OpportunityStatus', 'won')); $opportunity->setOrganization($organization); $opportunity->setCustomer($this->getReference('default_b2bcustomer')); /** @var B2bCustomer $b2bCustomer */ $b2bCustomer = $this->getReference('default_b2bcustomer'); $b2bCustomer->addOpportunity($opportunity); $em->persist($opportunity); $em->flush(); $em->remove($b2bCustomer); $em->flush(); }