Beispiel #1
0
 /**
  * Gets a list of all phone numbers available for the given Lead object
  *
  * @param Lead $object
  *
  * @return array of [phone number, phone owner]
  */
 public function getPhoneNumbers($object)
 {
     $result = [];
     $phone = $object->getPhoneNumber();
     if (!empty($phone)) {
         $result[] = [$phone, $object];
     }
     return $result;
 }
Beispiel #2
0
 public function testGetFirstName()
 {
     $salesFunnel = new SalesFunnel();
     $opportunity = new Opportunity();
     $opportunity->setName('test');
     $salesFunnel->setOpportunity($opportunity);
     $this->assertEquals('test', $salesFunnel->getFirstName());
     $salesFunnel = new SalesFunnel();
     $lead = new Lead();
     $lead->setName('test2');
     $salesFunnel->setLead($lead);
     $this->assertEquals('test2', $salesFunnel->getFirstName());
 }
Beispiel #3
0
 protected function createLead()
 {
     $lead = new Lead();
     $lead->setDataChannel($this->getReference('default_channel'));
     $lead->setName('Lead name');
     $lead->setFirstName('fname');
     $lead->setLastName('lname');
     $lead->setCustomer($this->getReference('default_b2bcustomer'));
     $lead->setEmail('*****@*****.**');
     $lead->setOrganization($this->organization);
     $this->em->persist($lead);
     $this->em->flush();
     $this->setReference('default_lead', $lead);
     return $this;
 }
Beispiel #4
0
 /**
  * @param string $key
  * @param Lead   $entity
  */
 public function fillEntityData($key, $entity)
 {
     $addressRepo = $this->templateManager->getEntityRepository('Oro\\Bundle\\AddressBundle\\Entity\\Address');
     $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');
     $channelRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\ChannelBundle\\Entity\\Channel');
     switch ($key) {
         case 'Jerry Coleman':
             $entity->setName('Oro Inc. Lead Name');
             $entity->setCompanyName('Oro Inc.');
             $entity->setOwner($userRepo->getEntity('John Doo'));
             $entity->setDataChannel($channelRepo->getEntity('B2b channel|b2b'));
             $entity->setCreatedAt(new \DateTime());
             $entity->setUpdatedAt(new \DateTime());
             $entity->setCustomer($customerRepo->getEntity('Jerry Coleman'));
             $entity->setContact($contactRepo->getEntity('Jerry Coleman'));
             $entity->setAddress($addressRepo->getEntity('Jerry Coleman'));
             $entity->setEmail('*****@*****.**');
             $entity->setNamePrefix('Mr.');
             $entity->setFirstName('Jerry');
             $entity->setLastName('Coleman');
             $entity->setNameSuffix('Jr.');
             $entity->setStatus(new LeadStatus('New'));
             $entity->setJobTitle('Manager');
             $entity->setPhoneNumber('585-255-1127');
             $entity->setWebsite('http://orocrm.com');
             $entity->setNumberOfEmployees(100);
             $entity->setIndustry('Internet');
             return;
     }
     parent::fillEntityData($key, $entity);
 }
Beispiel #5
0
 /**
  * @param  array $data
  * @param User   $user
  *
  * @return Lead
  */
 protected function createLead(array $data, $user)
 {
     $lead = new Lead();
     /** @var LeadStatus $defaultStatus */
     $defaultStatus = $this->em->find('OroCRMSalesBundle:LeadStatus', 'new');
     $lead->setStatus($defaultStatus);
     $lead->setName($data['Company']);
     $lead->setFirstName($data['GivenName']);
     $lead->setLastName($data['Surname']);
     $lead->setEmail($data['EmailAddress']);
     $lead->setPhoneNumber($data['TelephoneNumber']);
     $lead->setCompanyName($data['Company']);
     $lead->setOwner($user);
     $lead->setDataChannel($this->channel);
     /** @var Address $address */
     $address = new Address();
     $address->setLabel('Primary Address');
     $address->setCity($data['City']);
     $address->setStreet($data['StreetAddress']);
     $address->setPostalCode($data['ZipCode']);
     $address->setFirstName($data['GivenName']);
     $address->setLastName($data['Surname']);
     $isoCode = $data['Country'];
     $country = array_filter($this->countries, function (Country $a) use($isoCode) {
         return $a->getIso2Code() == $isoCode;
     });
     $country = array_values($country);
     /** @var Country $country */
     $country = $country[0];
     $idRegion = $data['State'];
     /** @var Collection $regions */
     $regions = $country->getRegions();
     $region = $regions->filter(function (Region $a) use($idRegion) {
         return $a->getCode() == $idRegion;
     });
     $address->setCountry($country);
     if (!$region->isEmpty()) {
         $address->setRegion($region->first());
     }
     $lead->setAddress($address);
     $countSources = count($this->sources) - 1;
     $source = $this->sources[mt_rand(0, $countSources)];
     $lead->setSource($source);
     return $lead;
 }
 /**
  * @param Lead | Opportunity $entity
  * @param User $owner
  */
 protected function loadSalesFlows($entity, $owner)
 {
     if ($entity instanceof Lead) {
         $step = 'start_from_lead';
         $parameters = array('lead' => $entity);
     } else {
         $step = 'start_from_opportunity';
         $parameters = array('opportunity' => $entity);
     }
     $parameters = array_merge(array('sales_funnel' => null, 'sales_funnel_owner' => $owner, 'sales_funnel_start_date' => new \DateTime('now')), $parameters);
     $salesFunnel = new SalesFunnel();
     $salesFunnel->setDataChannel($this->getReference('default_channel'));
     if (!$this->workflowManager->isStartTransitionAvailable('b2b_flow_sales_funnel', $step, $salesFunnel, $parameters)) {
         return;
     }
     $salesFunnelItem = $this->workflowManager->startWorkflow('b2b_flow_sales_funnel', $salesFunnel, $step, $parameters);
     $salesFunnelItem->getData()->set('new_opportunity_name', $entity->getName())->set('new_company_name', $entity->getName());
     if ($entity instanceof Lead) {
         if ($this->isTransitionAllowed($salesFunnelItem, 'qualify')) {
             $this->workflowManager->transit($salesFunnelItem, 'qualify');
         } else {
             return;
         }
     }
     if (rand(1, 100) > 10) {
         $salesFunnelItem->getData()->set('budget_amount', mt_rand(10, 10000))->set('customer_need', mt_rand(10, 10000))->set('proposed_solution', mt_rand(10, 10000))->set('probability', $this->probabilities[array_rand($this->probabilities)]);
         if ($this->isTransitionAllowed($salesFunnelItem, 'develop')) {
             $this->workflowManager->transit($salesFunnelItem, 'develop');
             if ($this->getRandomBoolean()) {
                 $salesFunnelItem->getData()->set('close_revenue', mt_rand(10, 1000))->set('close_date', new \DateTime());
                 if ($this->getRandomBoolean()) {
                     if ($this->isTransitionAllowed($salesFunnelItem, 'close_as_won')) {
                         $this->workflowManager->transit($salesFunnelItem, 'close_as_won');
                     }
                 } else {
                     $salesFunnelItem->getData()->set('close_reason_name', 'cancelled')->set('close_date', new \DateTime('now', new \DateTimeZone('UTC')));
                     if ($this->isTransitionAllowed($salesFunnelItem, 'close_as_lost')) {
                         $this->workflowManager->transit($salesFunnelItem, 'close_as_lost');
                     }
                 }
             }
         }
     }
 }
Beispiel #7
0
 /**
  * Create lead form with data channel
  *
  * @Route("/create/{channelIds}", name="orocrm_sales_lead_data_channel_aware_create")
  * @Template("OroCRMSalesBundle:Lead:update.html.twig")
  * @AclAncestor("orocrm_sales_lead_view")
  *
  * @ParamConverter(
  *      "channel",
  *      class="OroCRMChannelBundle:Channel",
  *      options={"id" = "channelIds"}
  * )
  */
 public function leadWithDataChannelCreateAction(Channel $channel)
 {
     $lead = new Lead();
     $lead->setDataChannel($channel);
     return $this->update($lead);
 }