Exemplo n.º 1
0
 public function loadReports()
 {
     foreach ($this->reports as $values) {
         $report = new Report();
         $report->setName($values['name']);
         $report->setDescription($values['description']);
         $report->setEntity($values['entity']);
         /** @var ReportType $type */
         $type = $this->em->getRepository('OroReportBundle:ReportType')->findOneBy(array('name' => $values['type']));
         $report->setType($type);
         /** @var BusinessUnit $owner */
         $owner = $this->em->getRepository('OroOrganizationBundle:BusinessUnit')->findOneBy(array('name' => $values['owner']));
         $report->setOwner($owner);
         $report->setDefinition($values['definition']);
         $report->setOrganization($this->organization);
         $this->persist($this->em, $report);
     }
     $this->flush($this->em);
 }
 /**
  * Load "Campaign Performance" report definition
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     /** @var EntityManager $em */
     $em = $this->container->get('doctrine.orm.default_entity_manager');
     $report = new Report();
     $report->setName('Campaign Performance');
     $report->setEntity('OroCRM\\Bundle\\CampaignBundle\\Entity\\Campaign');
     $type = $em->getReference('OroReportBundle:ReportType', ReportType::TYPE_TABLE);
     $report->setType($type);
     // @codingStandardsIgnoreStart
     $definition = ['filters' => [], 'columns' => [['name' => 'name', 'label' => 'Name', 'func' => '', 'sorting' => ''], ['name' => 'code', 'label' => 'Code', 'func' => '', 'sorting' => ''], ['name' => 'OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::campaign+OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::id', 'label' => 'Leads', 'func' => ['name' => 'Count', 'group_type' => 'aggregates', 'group_name' => 'number'], 'sorting' => ''], ['name' => 'OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::campaign+OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::opportunities+OroCRM\\Bundle\\SalesBundle\\Entity\\Opportunity::id', 'label' => 'Opportunities', 'func' => ['name' => 'Count', 'group_type' => 'aggregates', 'group_name' => 'number'], 'sorting' => ''], ['name' => 'OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::campaign+OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::opportunities+OroCRM\\Bundle\\SalesBundle\\Entity\\Opportunity::status_label', 'label' => 'Number Won', 'func' => ['name' => 'WonCount', 'group_type' => 'aggregates', 'group_name' => 'opportunity_status'], 'sorting' => ''], ['name' => 'OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::campaign+OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::opportunities+OroCRM\\Bundle\\SalesBundle\\Entity\\Opportunity::status_label', 'label' => 'Number Lost', 'func' => ['name' => 'LostCount', 'group_type' => 'aggregates', 'group_name' => 'opportunity_status'], 'sorting' => ''], ['name' => 'OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::campaign+OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::opportunities+OroCRM\\Bundle\\SalesBundle\\Entity\\Opportunity::closeRevenue', 'label' => 'Close revenue', 'func' => ['name' => 'WonRevenueSumFunction', 'group_type' => 'aggregates', 'group_name' => 'opportunity'], 'sorting' => 'DESC']], 'grouping_columns' => [['name' => 'code'], ['name' => 'name']]];
     // @codingStandardsIgnoreEnd
     $report->setDefinition(json_encode($definition));
     $report->setOrganization($manager->getRepository('OroOrganizationBundle:Organization')->getFirst());
     $report->setOwner($manager->getRepository('OroOrganizationBundle:BusinessUnit')->getFirst());
     $em->persist($report);
     $em->flush($report);
 }