/** * Add available tables and columns to the report builder lookup * * @param ReportBuilderEvent $event * * @return void */ public function onReportBuilder(ReportBuilderEvent $event) { if ($event->checkContext(array('emails', 'email.stats'))) { $prefix = 'e.'; $variantParent = 'vp.'; $columns = array($prefix . 'subject' => array('label' => 'mautic.email.subject', 'type' => 'string'), $prefix . 'lang' => array('label' => 'mautic.core.language', 'type' => 'string'), $prefix . 'read_count' => array('label' => 'mautic.email.report.read_count', 'type' => 'int'), $prefix . 'revision' => array('label' => 'mautic.email.report.revision', 'type' => 'int'), $variantParent . 'id' => array('label' => 'mautic.email.report.variant_parent_id', 'type' => 'int'), $variantParent . 'subject' => array('label' => 'mautic.email.report.variant_parent_subject', 'type' => 'string'), $prefix . 'variant_start_date' => array('label' => 'mautic.email.report.variant_start_date', 'type' => 'datetime'), $prefix . 'variant_sent_count' => array('label' => 'mautic.email.report.variant_sent_count', 'type' => 'int'), $prefix . 'variant_read_count' => array('label' => 'mautic.email.report.variant_read_count', 'type' => 'int')); $columns = array_merge($columns, $event->getStandardColumns($prefix), $event->getCategoryColumns()); $data = array('display_name' => 'mautic.email.emails', 'columns' => $columns); $event->addTable('emails', $data); if ($event->checkContext('email.stats')) { $statPrefix = 'es.'; $statColumns = array($statPrefix . 'email_address' => array('label' => 'mautic.email.report.stat.email_address', 'type' => 'email'), $statPrefix . 'date_sent' => array('label' => 'mautic.email.report.stat.date_sent', 'type' => 'datetime'), $statPrefix . 'is_read' => array('label' => 'mautic.email.report.stat.is_read', 'type' => 'bool'), $statPrefix . 'is_failed' => array('label' => 'mautic.email.report.stat.is_failed', 'type' => 'bool'), $statPrefix . 'viewed_in_browser' => array('label' => 'mautic.email.report.stat.viewed_in_browser', 'type' => 'bool'), $statPrefix . 'date_read' => array('label' => 'mautic.email.report.stat.date_read', 'type' => 'datetime'), $statPrefix . 'retry_count' => array('label' => 'mautic.email.report.stat.retry_count', 'type' => 'int'), $statPrefix . 'source' => array('label' => 'mautic.report.field.source', 'type' => 'string'), $statPrefix . 'source_id' => array('label' => 'mautic.report.field.source_id', 'type' => 'int')); $data = array('display_name' => 'mautic.email.stats.report.table', 'columns' => array_merge($columns, $statColumns, $event->getLeadColumns(), $event->getIpColumn())); $event->addTable('email.stats', $data); // Register Graphs $context = 'email.stats'; $event->addGraph($context, 'line', 'mautic.email.graph.line.stats'); $event->addGraph($context, 'pie', 'mautic.email.graph.pie.ignored.read.failed'); $event->addGraph($context, 'table', 'mautic.email.table.most.emails.sent'); $event->addGraph($context, 'table', 'mautic.email.table.most.emails.read'); $event->addGraph($context, 'table', 'mautic.email.table.most.emails.failed'); $event->addGraph($context, 'table', 'mautic.email.table.most.emails.read.percent'); } } }
/** * Add available tables and columns to the report builder lookup * * @param ReportBuilderEvent $event * * @return void */ public function onReportBuilder(ReportBuilderEvent $event) { if ($event->checkContext(array('pages', 'page.hits'))) { $prefix = 'p.'; $translationPrefix = 'tp.'; $variantPrefix = 'vp.'; $columns = array($prefix . 'title' => array('label' => 'mautic.core.title', 'type' => 'string'), $prefix . 'alias' => array('label' => 'mautic.core.alias', 'type' => 'string'), $prefix . 'revision' => array('label' => 'mautic.page.report.revision', 'type' => 'string'), $prefix . 'hits' => array('label' => 'mautic.page.field.hits', 'type' => 'int'), $prefix . 'unique_hits' => array('label' => 'mautic.page.field.unique_hits', 'type' => 'int'), $translationPrefix . 'id' => array('label' => 'mautic.page.report.translation_parent_id', 'type' => 'int'), $translationPrefix . 'title' => array('label' => 'mautic.page.report.translation_parent_title', 'type' => 'string'), $variantPrefix . 'id' => array('label' => 'mautic.page.report.variant_parent_id', 'type' => 'string'), $variantPrefix . 'title' => array('label' => 'mautic.page.report.variant_parent_title', 'type' => 'string'), $prefix . 'lang' => array('label' => 'mautic.core.language', 'type' => 'string'), $prefix . 'variant_start_date' => array('label' => 'mautic.page.report.variant_start_date', 'type' => 'datetime'), $prefix . 'variant_hits' => array('label' => 'mautic.page.report.variant_hits', 'type' => 'int')); $columns = array_merge($columns, $event->getStandardColumns('p.', array('name', 'description')), $event->getCategoryColumns()); $data = array('display_name' => 'mautic.page.pages', 'columns' => $columns); $event->addTable('pages', $data); if ($event->checkContext('page.hits')) { $hitPrefix = 'ph.'; $redirectHit = 'r.'; $emailPrefix = 'e.'; $hitColumns = array($hitPrefix . 'date_hit' => array('label' => 'mautic.page.report.hits.date_hit', 'type' => 'datetime'), $hitPrefix . 'date_left' => array('label' => 'mautic.page.report.hits.date_left', 'type' => 'datetime'), $hitPrefix . 'country' => array('label' => 'mautic.page.report.hits.country', 'type' => 'string'), $hitPrefix . 'region' => array('label' => 'mautic.page.report.hits.region', 'type' => 'string'), $hitPrefix . 'city' => array('label' => 'mautic.page.report.hits.city', 'type' => 'string'), $hitPrefix . 'isp' => array('label' => 'mautic.page.report.hits.isp', 'type' => 'string'), $hitPrefix . 'organization' => array('label' => 'mautic.page.report.hits.organization', 'type' => 'string'), $hitPrefix . 'code' => array('label' => 'mautic.page.report.hits.code', 'type' => 'int'), $hitPrefix . 'referer' => array('label' => 'mautic.page.report.hits.referer', 'type' => 'string'), $hitPrefix . 'url' => array('label' => 'mautic.page.report.hits.url', 'type' => 'url'), $hitPrefix . 'url_title' => array('label' => 'mautic.page.report.hits.url_title', 'type' => 'string'), $hitPrefix . 'user_agent' => array('label' => 'mautic.page.report.hits.user_agent', 'type' => 'string'), $hitPrefix . 'remote_host' => array('label' => 'mautic.page.report.hits.remote_host', 'type' => 'string'), $hitPrefix . 'browser_languages' => array('label' => 'mautic.page.report.hits.browser_languages', 'type' => 'array'), $hitPrefix . 'source' => array('label' => 'mautic.report.field.source', 'type' => 'string'), $hitPrefix . 'source_id' => array('label' => 'mautic.report.field.source_id', 'type' => 'int'), $redirectHit . 'url' => array('label' => 'mautic.page.report.hits.redirect_url', 'type' => 'url'), $redirectHit . 'hits' => array('label' => 'mautic.page.report.hits.redirect_hit_count', 'type' => 'int'), $redirectHit . 'unique_hits' => array('label' => 'mautic.page.report.hits.redirect_unique_hits', 'type' => 'string'), $emailPrefix . 'id' => array('label' => 'mautic.page.report.hits.email_id', 'type' => 'int'), $emailPrefix . 'subject' => array('label' => 'mautic.page.report.hits.email_subject', 'type' => 'string')); $data = array('display_name' => 'mautic.page.hits', 'columns' => array_merge($columns, $hitColumns, $event->getLeadColumns(), $event->getIpColumn())); $event->addTable('page.hits', $data); // Register graphs $context = 'page.hits'; $event->addGraph($context, 'line', 'mautic.page.graph.line.hits'); $event->addGraph($context, 'line', 'mautic.page.graph.line.time.on.site'); $event->addGraph($context, 'pie', 'mautic.page.graph.pie.time.on.site', array('translate' => false)); $event->addGraph($context, 'pie', 'mautic.page.graph.pie.new.vs.returning'); $event->addGraph($context, 'pie', 'mautic.page.graph.pie.languages', array('translate' => false)); $event->addGraph($context, 'table', 'mautic.page.table.referrers'); $event->addGraph($context, 'table', 'mautic.page.table.most.visited'); $event->addGraph($context, 'table', 'mautic.page.table.most.visited.unique'); } } }
/** * Add available tables and columns to the report builder lookup * * @param ReportBuilderEvent $event * * @return void */ public function onReportBuilder(ReportBuilderEvent $event) { if ($event->checkContext(array('leads', 'lead.pointlog'))) { $prefix = 'l.'; $userPrefix = 'u.'; $ipPrefix = 'i.'; $columns = array($ipPrefix . 'ip_address' => array('label' => 'mautic.core.ipaddress', 'type' => 'text'), $prefix . 'date_identified' => array('label' => 'mautic.lead.report.date_identified', 'type' => 'datetime'), $prefix . 'points' => array('label' => 'mautic.lead.points', 'type' => 'int'), $prefix . 'owner_id' => array('label' => 'mautic.lead.report.owner_id', 'type' => 'int'), $userPrefix . 'first_name' => array('label' => 'mautic.lead.report.owner_firstname', 'type' => 'string'), $userPrefix . 'last_name' => array('label' => 'mautic.lead.report.owner_lastname', 'type' => 'string')); /** @var \Mautic\LeadBundle\Model\FieldModel $model */ $model = $this->factory->getModel('lead.field'); $leadFields = $model->getEntities(); $fieldColumns = array(); foreach ($leadFields as $f) { switch ($f->getType()) { case 'boolean': $type = 'bool'; break; case 'date': case 'datetime': case 'time': $type = 'datetime'; break; case 'url': $type = 'url'; break; case 'email': $type = 'email'; break; default: $type = 'string'; break; } $fieldColumns[$prefix . $f->getAlias()] = array('label' => $f->getLabel(), 'type' => $type); } $columns = array_merge($columns, $fieldColumns); $data = array('display_name' => 'mautic.lead.leads', 'columns' => $columns); $event->addTable('leads', $data); // Add graphs $event->addGraph('leads', 'line', 'mautic.lead.graph.line.leads'); if ($event->checkContext('lead.pointlog')) { $pointPrefix = 'lp.'; $pointColumns = array($pointPrefix . 'type' => array('label' => 'mautic.lead.report.points.type', 'type' => 'string'), $pointPrefix . 'event_name' => array('label' => 'mautic.lead.report.points.event_name', 'type' => 'string'), $pointPrefix . 'action_name' => array('label' => 'mautic.lead.report.points.action_name', 'type' => 'string'), $pointPrefix . 'delta' => array('label' => 'mautic.lead.report.points.delta', 'type' => 'int'), $pointPrefix . 'date_added' => array('label' => 'mautic.lead.report.points.date_added', 'type' => 'datetime')); $data = array('display_name' => 'mautic.lead.report.points.table', 'columns' => array_merge($columns, $pointColumns, $event->getIpColumn())); $event->addTable('lead.pointlog', $data); // Register graphs $context = 'lead.pointlog'; $event->addGraph($context, 'line', 'mautic.lead.graph.line.points'); $event->addGraph($context, 'table', 'mautic.lead.table.most.points'); $event->addGraph($context, 'table', 'mautic.lead.table.top.countries'); $event->addGraph($context, 'table', 'mautic.lead.table.top.cities'); $event->addGraph($context, 'table', 'mautic.lead.table.top.events'); $event->addGraph($context, 'table', 'mautic.lead.table.top.actions'); } } }
public function onReportBuilder(ReportBuilderEvent $event) { if ($event->checkContext(array('task'))) { // Task fields $prefix = 't.'; $columns = array($prefix . 'id' => array('label' => 'mautic.core.id', 'type' => 'id'), $prefix . 'name' => array('label' => 'ddi.lead_actions.tasks.report.field.name', 'type' => 'string'), $prefix . 'date_added' => array('label' => 'mautic.report.field.date_added', 'type' => 'datetime'), $prefix . 'date_completed' => array('label' => 'ddi.lead_actions.tasks.report.field.date_completed', 'type' => 'datetime'), $prefix . 'due_date' => array('label' => 'ddi.lead_actions.tasks.report.field.due_date', 'type' => 'datetime'), $prefix . 'is_completed' => array('label' => 'ddi.lead_actions.tasks.report.field.is_completed', 'type' => 'int')); // Assign user fields $userPrefix = 'u.'; $userColumns = array($userPrefix . 'id' => array('label' => 'Assigned user ID', 'type' => 'int'), $userPrefix . 'first_name' => array('label' => 'Assigned user first name', 'type' => 'string'), $userPrefix . 'last_name' => array('label' => 'Assigned user last name', 'type' => 'string')); $event->addTable('task', array('display_name' => 'Tasks', 'columns' => array_merge($columns, $event->getLeadColumns(), $userColumns))); } if ($event->checkContext(array('opportunity'))) { $prefix = 'op.'; $columns = array($prefix . 'status' => array('label' => 'Status', 'type' => 'string'), $prefix . 'confidence' => array('label' => 'Confidence', 'type' => 'int'), $prefix . 'value' => array('label' => 'Value', 'type' => 'int'), $prefix . 'value_type' => array('label' => 'Type', 'type' => 'string'), $prefix . 'estimated_close' => array('label' => 'Estimated Close', 'type' => 'datetime'), $prefix . 'comments' => array('label' => 'Comments', 'type' => 'string')); // Assign user fields $userPrefix = 'u.'; $userColumns = array($userPrefix . 'id' => array('label' => 'Assigned user ID', 'type' => 'int'), $userPrefix . 'first_name' => array('label' => 'Assigned user first name', 'type' => 'string'), $userPrefix . 'last_name' => array('label' => 'Assigned user last name', 'type' => 'string')); $event->addTable('opportunity', array('display_name' => 'Opportunities', 'columns' => array_merge($columns, $event->getLeadColumns(), $userColumns))); } }
/** * Add available tables and columns to the report builder lookup * * @param ReportBuilderEvent $event * * @return void */ public function onReportBuilder(ReportBuilderEvent $event) { if ($event->checkContext(['assets', 'asset.downloads'])) { // Assets $prefix = 'a.'; $columns = [$prefix . 'download_count' => ['label' => 'mautic.asset.report.download_count', 'type' => 'int'], $prefix . 'unique_download_count' => ['label' => 'mautic.asset.report.unique_download_count', 'type' => 'int'], $prefix . 'alias' => ['label' => 'mautic.core.alias', 'type' => 'string'], $prefix . 'lang' => ['label' => 'mautic.core.language', 'type' => 'string'], $prefix . 'title' => ['label' => 'mautic.core.title', 'type' => 'string']]; $columns = array_merge($columns, $event->getStandardColumns($prefix, ['name'], 'mautic_asset_action'), $event->getCategoryColumns()); $event->addTable('assets', ['display_name' => 'mautic.asset.assets', 'columns' => $columns]); if ($event->checkContext(['asset.downloads'])) { // Downloads $downloadPrefix = 'ad.'; $downloadColumns = [$downloadPrefix . 'date_download' => ['label' => 'mautic.asset.report.download.date_download', 'type' => 'datetime'], $downloadPrefix . 'code' => ['label' => 'mautic.asset.report.download.code', 'type' => 'string'], $downloadPrefix . 'referer' => ['label' => 'mautic.core.referer', 'type' => 'string'], $downloadPrefix . 'source' => ['label' => 'mautic.report.field.source', 'type' => 'string'], $downloadPrefix . 'source_id' => ['label' => 'mautic.report.field.source_id', 'type' => 'int']]; $event->addTable('asset.downloads', ['display_name' => 'mautic.asset.report.downloads.table', 'columns' => array_merge($columns, $downloadColumns, $event->getLeadColumns(), $event->getIpColumn())], 'assets'); // Add Graphs $context = 'asset.downloads'; $event->addGraph($context, 'line', 'mautic.asset.graph.line.downloads'); $event->addGraph($context, 'table', 'mautic.asset.table.most.downloaded'); $event->addGraph($context, 'table', 'mautic.asset.table.top.referrers'); $event->addGraph($context, 'pie', 'mautic.asset.graph.pie.statuses', ['translate' => false]); } } }
/** * Add available tables and columns to the report builder lookup. * * @param ReportBuilderEvent $event */ public function onReportBuilder(ReportBuilderEvent $event) { if ($event->checkContext(['forms', 'form.submissions'])) { // Forms $prefix = 'f.'; $columns = [$prefix . 'alias' => ['label' => 'mautic.core.alias', 'type' => 'string']]; $columns = array_merge($columns, $event->getStandardColumns($prefix, [], 'mautic_form_action'), $event->getCategoryColumns()); $data = ['display_name' => 'mautic.form.forms', 'columns' => $columns]; $event->addTable('forms', $data); if ($event->checkContext('form.submissions')) { // Form submissions $submissionPrefix = 'fs.'; $pagePrefix = 'p.'; $submissionColumns = [$submissionPrefix . 'date_submitted' => ['label' => 'mautic.form.report.submit.date_submitted', 'type' => 'datetime'], $submissionPrefix . 'referer' => ['label' => 'mautic.core.referer', 'type' => 'string'], $pagePrefix . 'id' => ['label' => 'mautic.form.report.page_id', 'type' => 'int', 'link' => 'mautic_page_action'], $pagePrefix . 'name' => ['label' => 'mautic.form.report.page_name', 'type' => 'string']]; $data = ['display_name' => 'mautic.form.report.submission.table', 'columns' => array_merge($submissionColumns, $columns, $event->getLeadColumns(), $event->getIpColumn())]; $event->addTable('form.submissions', $data, 'forms'); // Register graphs $context = 'form.submissions'; $event->addGraph($context, 'line', 'mautic.form.graph.line.submissions'); $event->addGraph($context, 'table', 'mautic.form.table.top.referrers'); $event->addGraph($context, 'table', 'mautic.form.table.most.submitted'); } } }
/** * @param ReportBuilderEvent $event * @param array $columns */ private function injectAttributionReportData(ReportBuilderEvent $event, array $columns, $type) { $attributionColumns = ['log.campaign_id' => ['label' => 'mautic.lead.report.attribution.campaign_id', 'type' => 'int', 'link' => 'mautic_campaign_action'], 'log.date_triggered' => ['label' => 'mautic.lead.report.attribution.action_date', 'type' => 'datetime'], 'c.name' => ['alias' => 'campaign_name', 'label' => 'mautic.lead.report.attribution.campaign_name', 'type' => 'string'], 'l.stage_id' => ['label' => 'mautic.lead.report.attribution.stage_id', 'type' => 'int', 'link' => 'mautic_stage_action'], 's.name' => ['alias' => 'stage_name', 'label' => 'mautic.lead.report.attribution.stage_name', 'type' => 'string'], 'channel' => ['alias' => 'channel', 'formula' => 'SUBSTRING_INDEX(e.type, \'.\', 1)', 'label' => 'mautic.lead.report.attribution.channel', 'type' => 'string'], 'channel_action' => ['alias' => 'channel_action', 'formula' => 'SUBSTRING_INDEX(e.type, \'.\', -1)', 'label' => 'mautic.lead.report.attribution.channel_action', 'type' => 'string'], 'e.name' => ['alias' => 'action_name', 'label' => 'mautic.lead.report.attribution.action_name', 'type' => 'string']]; $filters = $columns = array_merge($columns, $event->getCategoryColumns('cat.'), $attributionColumns); // Setup available channels $availableChannels = $this->campaignModel->getEvents(); $channels = []; $channelActions = []; foreach ($availableChannels['decision'] as $channel => $decision) { $parts = explode('.', $channel); $channelName = $parts[0]; $channels[$channelName] = $this->translator->hasId('mautic.channel.' . $channelName) ? $this->translator->trans('mautic.channel.' . $channelName) : ucfirst($channelName); unset($parts[0]); $actionValue = implode('.', $parts); if ($this->translator->hasId('mautic.channel.action.' . $channel)) { $actionName = $this->translator->trans('mautic.channel.action.' . $channel); } elseif ($this->translator->hasId('mautic.campaign.' . $channel)) { $actionName = $this->translator->trans('mautic.campaign.' . $channel); } else { $actionName = $channelName . ': ' . $actionValue; } $channelActions[$actionValue] = $actionName; } $filters['channel'] = ['label' => 'mautic.lead.report.attribution.channel', 'type' => 'select', 'list' => $channels]; $filters['channel_action'] = ['label' => 'mautic.lead.report.attribution.channel_action', 'type' => 'select', 'list' => $channelActions]; $this->channelActions = $channelActions; $this->channels = $channels; unset($channelActions, $channels); // Setup available channels $campaigns = $this->campaignModel->getRepository()->getSimpleList(); $filters['log.campaign_id'] = ['label' => 'mautic.lead.report.attribution.filter.campaign', 'type' => 'select', 'list' => $campaigns]; unset($campaigns); // Setup stages list $userStages = $this->stageModel->getUserStages(); $stages = []; foreach ($userStages as $stage) { $stages[$stage['id']] = $stage['name']; } $filters['l.stage_id'] = ['label' => 'mautic.lead.report.attribution.filter.stage', 'type' => 'select', 'list' => $stages]; unset($stages); $context = "contact.attribution.{$type}"; $event->addGraph($context, 'pie', 'mautic.lead.graph.pie.attribution_stages')->addGraph($context, 'pie', 'mautic.lead.graph.pie.attribution_campaigns')->addGraph($context, 'pie', 'mautic.lead.graph.pie.attribution_actions')->addGraph($context, 'pie', 'mautic.lead.graph.pie.attribution_channels'); $data = ['display_name' => 'mautic.lead.report.attribution.' . $type, 'columns' => $columns, 'filters' => $filters]; $event->addTable($context, $data, 'contacts'); }