/**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $businessUnitName = 'bu1';
     $organizationsCount = 3;
     /** @var Organization[] $organizations */
     $organizations = [];
     for ($i = 1; $i <= $organizationsCount; $i++) {
         $key = 'org' . $i;
         $organizations[$key] = new Organization();
         $organizations[$key]->setName($key)->setEnabled(true);
         $manager->persist($organizations[$key]);
         $this->addReference($key, $organizations[$key]);
     }
     $businessUnit = new BusinessUnit();
     $businessUnit->setName($businessUnitName)->setOrganization($organizations['org1']);
     $manager->persist($businessUnit);
     $this->addReference('bu1', $businessUnit);
     $userManager = $this->container->get('oro_user.manager');
     /** @var User $user */
     $user = $userManager->createUser();
     $user->setUsername('test_user_main')->setPlainPassword('admin')->setEmail('*****@*****.**')->setEnabled(true);
     $userManager->updateUser($user, false);
     $this->setReference($user->getUsername(), $user);
     $manager->flush();
 }
Пример #2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     /** @var Organization $organization */
     $organization = $this->organizationRepository->getFirst();
     $this->addReference('default_organization', $organization);
     /** @var BusinessUnit $oroMain */
     $oroMain = $this->businessUnitRepository->findOneBy(array('name' => 'Main'));
     if (!$oroMain) {
         $oroMain = $this->businessUnitRepository->findOneBy(array('name' => 'Acme, General'));
     }
     if (!$oroMain) {
         throw new \Exception('"Main" business unit is not defined');
     }
     $oroMain->setName('Acme, General');
     $oroMain->setEmail('*****@*****.**');
     $oroMain->setPhone('798-682-5917');
     $this->persistAndFlush($this->organizationManager, $oroMain);
     $this->addReference('default_main_business', $oroMain);
     /** @var BusinessUnit $oroUnit */
     $oroUnit = new BusinessUnit();
     /** @var BusinessUnit $mageCoreUnit */
     $mageCoreUnit = new BusinessUnit();
     $oroUnit->setName('Acme, West')->setWebsite('http://www.orocrm.com')->setOrganization($organization)->setEmail('*****@*****.**')->setPhone('798-682-5918')->setOwner($oroMain);
     $this->persist($this->organizationManager, $oroUnit);
     $this->addReference('default_crm_business', $oroUnit);
     $mageCoreUnit->setName('Acme, East')->setWebsite('http://www.magecore.com/')->setOrganization($organization)->setEmail('*****@*****.**')->setPhone('798-682-5919')->setOwner($oroMain);
     $this->persistAndFlush($this->organizationManager, $mageCoreUnit);
     $this->addReference('default_core_business', $mageCoreUnit);
 }
 public function load(ObjectManager $manager)
 {
     $defaultBusinessUnit = new BusinessUnit();
     $defaultBusinessUnit->setName('Main')->setOrganization($this->getReference('default_organization'));
     $this->addReference('default_business_unit', $defaultBusinessUnit);
     $manager->persist($defaultBusinessUnit);
     $manager->flush();
 }
Пример #4
0
 /**
  * @param string       $key
  * @param BusinessUnit $entity
  */
 public function fillEntityData($key, $entity)
 {
     switch ($key) {
         case 'Main':
             $entity->setName($key);
             return;
     }
     parent::fillEntityData($key, $entity);
 }
 /**
  * Gets a list of all phone numbers available for the given BusinessUnit object
  *
  * @param BusinessUnit $object
  *
  * @return array of [phone number, phone owner]
  */
 public function getPhoneNumbers($object)
 {
     $result = [];
     $phone = $object->getPhone();
     if (!empty($phone)) {
         $result[] = [$phone, $object];
     }
     return $result;
 }
Пример #6
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $organization = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst();
     $businessUnit = new BusinessUnit();
     $businessUnit->setOrganization($organization);
     $businessUnit->setName('TestBusinessUnit');
     $manager->persist($businessUnit);
     $this->setReference('TestBusinessUnit', $businessUnit);
     $manager->flush();
 }
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     // load default organization
     $defaultOrganization = new Organization();
     $defaultOrganization->setName(self::MAIN_ORGANIZATION)->setEnabled(true);
     $this->addReference('default_organization', $defaultOrganization);
     $manager->persist($defaultOrganization);
     // load default business unit
     $defaultBusinessUnit = new BusinessUnit();
     $defaultBusinessUnit->setName(self::MAIN_BUSINESS_UNIT)->setOrganization($defaultOrganization);
     $this->addReference('default_business_unit', $defaultBusinessUnit);
     $manager->persist($defaultBusinessUnit);
     $manager->flush();
 }
 public function testUser()
 {
     $businessUnit = new BusinessUnit();
     $user = new User();
     $businessUnit->setUsers(new ArrayCollection(array($user)));
     $this->assertContains($user, $businessUnit->getUsers());
     $businessUnit->removeUser($user);
     $this->assertNotContains($user, $businessUnit->getUsers());
     $businessUnit->addUser($user);
     $this->assertContains($user, $businessUnit->getUsers());
 }
Пример #9
0
 public function load(ObjectManager $manager)
 {
     $staticType = $manager->getRepository('OroSegmentBundle:SegmentType')->find(SegmentType::TYPE_STATIC);
     if (!$staticType) {
         $staticType = new SegmentType(SegmentType::TYPE_STATIC);
         $staticType->setLabel('Static');
         $manager->persist($staticType);
     }
     $dynamicType = $manager->getRepository('OroSegmentBundle:SegmentType')->find(SegmentType::TYPE_DYNAMIC);
     if (!$dynamicType) {
         $dynamicType = new SegmentType(SegmentType::TYPE_DYNAMIC);
         $dynamicType->setLabel('Dynamic');
         $manager->persist($dynamicType);
     }
     $organisation = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst();
     $owner = $manager->getRepository('OroOrganizationBundle:BusinessUnit')->findOneBy(array('name' => 'Test'));
     if (!$owner) {
         $owner = new BusinessUnit();
         $owner->setName('Test');
         $owner->setOrganization($organisation);
         $manager->persist($owner);
     }
     for ($i = 1; $i <= self::COUNT; $i++) {
         $definition = array('columns' => array('func' => null, 'label' => 'label' . $i, 'name' => '', 'sorting' => ''), 'filters' => array());
         $entity = new Segment();
         $entity->setCreatedAt(new \DateTime('now'));
         $entity->setDefinition(json_encode($definition));
         $entity->setDescription('description_' . $i);
         $entity->setEntity('Oro\\Bundle\\TestFrameworkBundle\\Entity\\WorkflowAwareEntity');
         $entity->setLastRun(new \DateTime('now'));
         $entity->setName('segment_' . $i);
         $entity->setOwner($owner);
         $entity->setType(rand(0, 100) % 2 ? $staticType : $dynamicType);
         $entity->setUpdatedAt(new \DateTime('now'));
         $entity->setOrganization($organisation);
         $manager->persist($entity);
     }
     $manager->flush();
 }
Пример #10
0
 public function testForecastOfOpportunitiesValuesWithBusinessUnits()
 {
     $user = new User();
     $user->setId(1);
     $businessUnit = new BusinessUnit();
     $businessUnit->addUser($user);
     $options = ['owners' => [], 'businessUnits' => [$businessUnit]];
     $widgetOptions = new WidgetOptionBag($options);
     $this->opportunityRepository->expects($this->any())->method('getForecastOfOpporunitiesData')->with([$user->getId()], null, $this->aclHelper)->will($this->returnValue(['inProgressCount' => 5, 'budgetAmount' => 1000, 'weightedForecast' => 500]));
     $this->businessUnitRepository->expects($this->any())->method('findById')->will($this->returnValue([$businessUnit]));
     $result = $this->provider->getForecastOfOpportunitiesValues($widgetOptions, 'getInProgressValues', 'integer', false);
     $this->assertEquals(['value' => 5], $result);
     $result = $this->provider->getForecastOfOpportunitiesValues($widgetOptions, 'getTotalForecastValues', 'currency', false);
     $this->assertEquals(['value' => 1000], $result);
     $result = $this->provider->getForecastOfOpportunitiesValues($widgetOptions, 'getWeightedForecastValues', 'currency', false);
     $this->assertEquals(['value' => 500], $result);
 }
 /**
  * @param BusinessUnit $businessUnit
  *
  * @return string
  */
 protected function getBusinessUnitName(BusinessUnit $businessUnit)
 {
     return $businessUnit->getName();
 }