PageRenderTime 53ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/src/OroCRM/Bundle/SalesBundle/Migrations/Data/ORM/LoadCampaignPerformanceReport.php

https://github.com/jrcollado1987/crm
PHP | 124 lines | 100 code | 9 blank | 15 comment | 0 complexity | 3a657d587bab820f801dd53a1d69e737 MD5 | raw file
  1. <?php
  2. namespace OroCRM\Bundle\SalesBundle\Migrations\Data\ORM;
  3. use Doctrine\ORM\EntityManager;
  4. use Doctrine\Common\Persistence\ObjectManager;
  5. use Doctrine\Common\DataFixtures\AbstractFixture;
  6. use Doctrine\Common\DataFixtures\DependentFixtureInterface;
  7. use Oro\Bundle\ReportBundle\Entity\Report;
  8. use Symfony\Component\DependencyInjection\ContainerInterface;
  9. use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  10. class LoadCampaignPerformanceReport extends AbstractFixture implements
  11. ContainerAwareInterface,
  12. DependentFixtureInterface
  13. {
  14. /** @var ContainerInterface */
  15. protected $container;
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public function getDependencies()
  20. {
  21. return [
  22. 'Oro\Bundle\ReportBundle\Migrations\Data\ORM\LoadReportTypes'
  23. ];
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function setContainer(ContainerInterface $container = null)
  29. {
  30. $this->container = $container;
  31. }
  32. /**
  33. * Load "Campaign Performance" report definition
  34. *
  35. * @param ObjectManager $manager
  36. */
  37. public function load(ObjectManager $manager)
  38. {
  39. /** @var EntityManager $em */
  40. $em = $this->container->get('doctrine.orm.default_entity_manager');
  41. $report = new Report();
  42. $report->setName('Campaign Performance');
  43. $report->setEntity('OroCRM\Bundle\CampaignBundle\Entity\Campaign');
  44. $type = $em->getReference('OroReportBundle:ReportType', 'TABLE');
  45. $report->setType($type);
  46. // @codingStandardsIgnoreStart
  47. $definition = [
  48. 'filters' => [],
  49. 'columns' => [
  50. ['name' => 'name', 'label' => 'Name', 'func' => '', 'sorting' => ''],
  51. ['name' => 'code', 'label' => 'Code', 'func' => '', 'sorting' => ''],
  52. [
  53. 'name' => 'OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::campaign+OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::id',
  54. 'label' => 'Leads',
  55. 'func' => [
  56. 'name' => 'Count',
  57. 'group_type' => 'aggregates',
  58. 'group_name' => 'number'
  59. ],
  60. 'sorting' => ''
  61. ],
  62. [
  63. 'name' => 'OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::campaign+OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::opportunities+OroCRM\\Bundle\\SalesBundle\\Entity\\Opportunity::id',
  64. 'label' => 'Opportunities',
  65. 'func' => [
  66. 'name' => 'Count',
  67. 'group_type' => 'aggregates',
  68. 'group_name' => 'number'
  69. ],
  70. 'sorting' => ''
  71. ],
  72. [
  73. 'name' => 'OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::campaign+OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::opportunities+OroCRM\\Bundle\\SalesBundle\\Entity\\Opportunity::status_label',
  74. 'label' => 'Number Won',
  75. 'func' => [
  76. 'name' => 'WonCount',
  77. 'group_type' => 'aggregates',
  78. 'group_name' => 'opportunity_status'
  79. ],
  80. 'sorting' => ''
  81. ],
  82. [
  83. 'name' => 'OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::campaign+OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::opportunities+OroCRM\\Bundle\\SalesBundle\\Entity\\Opportunity::status_label',
  84. 'label' => 'Number Lost',
  85. 'func' => [
  86. 'name' => 'LostCount',
  87. 'group_type' => 'aggregates',
  88. 'group_name' => 'opportunity_status'
  89. ],
  90. 'sorting' => ''
  91. ],
  92. [
  93. 'name' => 'OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::campaign+OroCRM\\Bundle\\SalesBundle\\Entity\\Lead::opportunities+OroCRM\\Bundle\\SalesBundle\\Entity\\Opportunity::closeRevenue',
  94. 'label' => 'Close revenue',
  95. 'func' => [
  96. 'name' => 'WonRevenueSumFunction',
  97. 'group_type' => 'aggregates',
  98. 'group_name' => 'opportunity'
  99. ],
  100. 'sorting' => 'DESC'
  101. ]
  102. ],
  103. 'grouping_columns' => [
  104. [
  105. 'name' => 'id',
  106. 'oro_report_form[grouping][columnNames]' => 'id'
  107. ]
  108. ]
  109. ];
  110. // @codingStandardsIgnoreEnd
  111. $report->setDefinition(json_encode($definition));
  112. $em->persist($report);
  113. $em->flush($report);
  114. }
  115. }