Пример #1
0
 /**
  * Get a stats for email by list
  *
  * @param Email|int $email
  * @param bool      $includeVariants
  *
  * @return array
  */
 public function getEmailListStats($email, $includeVariants = false)
 {
     if (!$email instanceof Email) {
         $email = $this->getEntity($email);
     }
     if ($includeVariants && $email->isVariant()) {
         $parent = $email->getVariantParent();
         if ($parent) {
             // $email is a variant of another
             $children = $parent->getVariantChildren();
             $emailIds = $children->getKeys();
             $emailIds[] = $parent->getId();
         } else {
             $children = $email->getVariantChildren();
             $emailIds = $children->getKeys();
             $emailIds[] = $email->getId();
         }
     } else {
         $emailIds = array($email->getId());
     }
     $lists = $email->getLists();
     $listCount = count($lists);
     $combined = $this->translator->trans('mautic.email.lists.combined');
     $datasets = array($combined => array(0, 0, 0));
     $labels = array($this->translator->trans('mautic.email.sent'), $this->translator->trans('mautic.email.read'), $this->translator->trans('mautic.email.failed'));
     if ($listCount) {
         /** @var \Mautic\EmailBundle\Entity\StatRepository $statRepo */
         $statRepo = $this->em->getRepository('MauticEmailBundle:Stat');
         foreach ($lists as $l) {
             $name = $l->getName();
             $sentCount = $statRepo->getSentCount($emailIds, $l->getId());
             $datasets[$combined][0] += $sentCount;
             $readCount = $statRepo->getReadCount($emailIds, $l->getId());
             $datasets[$combined][1] += $readCount;
             $failedCount = $statRepo->getFailedCount($emailIds, $l->getId());
             $datasets[$combined][2] += $failedCount;
             $datasets[$name] = array();
             $datasets[$name] = array($sentCount, $readCount, $failedCount);
             $datasets[$name]['datasetKey'] = $l->getId();
         }
     }
     if ($listCount === 1) {
         unset($datasets[$combined]);
     }
     $data = GraphHelper::prepareBarGraphData($labels, $datasets);
     return $data;
 }
Пример #2
0
 /**
  * Get a stats for notification by list
  *
  * @param Notification|int $notification
  *
  * @return array
  */
 public function getNotificationListStats($notification)
 {
     if (!$notification instanceof Notification) {
         $notification = $this->getEntity($notification);
     }
     $notificationIds = array($notification->getId());
     $lists = $notification->getLists();
     $listCount = count($lists);
     $combined = $this->translator->trans('mautic.notification.lists.combined');
     $datasets = array($combined => array(0, 0, 0));
     $labels = array($this->translator->trans('mautic.notification.sent'), $this->translator->trans('mautic.notification.read'), $this->translator->trans('mautic.notification.failed'));
     if ($listCount) {
         /** @var \Mautic\NotificationBundle\Entity\StatRepository $statRepo */
         $statRepo = $this->em->getRepository('MauticNotificationBundle:Stat');
         foreach ($lists as $l) {
             $name = $l->getTitle();
             $sentCount = $statRepo->getSentCount($notificationIds, $l->getId());
             $datasets[$combined][0] += $sentCount;
             $readCount = $statRepo->getReadCount($notificationIds, $l->getId());
             $datasets[$combined][1] += $readCount;
             $datasets[$name] = array();
             $datasets[$name] = array($sentCount, $readCount);
             $datasets[$name]['datasetKey'] = $l->getId();
         }
     }
     if ($listCount === 1) {
         unset($datasets[$combined]);
     }
     $data = GraphHelper::prepareBarGraphData($labels, $datasets);
     return $data;
 }
Пример #3
0
 /**
  * Get a stats for email by list
  *
  * @param Email $entity
  *
  * @return array
  */
 public function getEmailListStats(Email $entity)
 {
     $lists = $entity->getLists();
     $listCount = count($lists);
     $combined = $this->translator->trans('mautic.email.lists.combined');
     $datasets = array($combined => array(0, 0, 0));
     $labels = array($this->translator->trans('mautic.email.sent'), $this->translator->trans('mautic.email.read'), $this->translator->trans('mautic.email.failed'));
     if ($listCount) {
         $statRepo = $this->em->getRepository('MauticEmailBundle:Stat');
         foreach ($lists as $l) {
             $name = $l->getName();
             $sentCount = $statRepo->getSentCount($entity->getId(), $l->getId());
             $datasets[$combined][0] += $sentCount;
             $readCount = $statRepo->getReadCount($entity->getId(), $l->getId());
             $datasets[$combined][1] += $readCount;
             $failedCount = $statRepo->getFailedCount($entity->getId(), $l->getId());
             $datasets[$combined][2] += $failedCount;
             $datasets[$name] = array();
             $datasets[$name] = array($sentCount, $readCount, $failedCount);
             $datasets[$name]['datasetKey'] = $l->getId();
         }
     }
     if ($listCount === 1) {
         unset($datasets[$combined]);
     }
     $data = GraphHelper::prepareBarGraphData($labels, $datasets);
     return $data;
 }
Пример #4
0
<?php

/**
 * @package     Mautic
 * @copyright   2014 Mautic Contributors. All rights reserved.
 * @author      Mautic
 * @link        http://mautic.org
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
$support = $results['support'];
$label = $view['translator']->trans($variants['criteria'][$results['basedOn']]['label']);
$barData = \Mautic\CoreBundle\Helper\GraphHelper::prepareBarGraphData($support['labels'], $support['data']);
?>
<div class="panel ovf-h bg-auto bg-light-xs abtest-bar-chart">
    <div class="panel-body box-layout">
        <div class="col-xs-8 va-m">
            <h5 class="text-white dark-md fw-sb mb-xs">
                <?php 
echo $label;
?>
            </h5>
        </div>
        <div class="col-xs-4 va-t text-right">
            <h3 class="text-white dark-sm"><span class="fa fa-bar-chart"></span></h3>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-7">
            <canvas id="abtest-bar-chart" height="300"></canvas>
        </div>
        <div class="col-sm-5">
Пример #5
0
 /**
  * Get a stats for sms by list
  *
  * @param Sms|int $sms
  *
  * @return array
  */
 public function getSmsListStats($sms)
 {
     if (!$sms instanceof Sms) {
         $sms = $this->getEntity($sms);
     }
     $smsIds = array($sms->getId());
     $lists = $sms->getLists();
     $listCount = count($lists);
     $combined = $this->translator->trans('mautic.sms.lists.combined');
     $datasets = array($combined => array(0, 0, 0));
     $labels = array($this->translator->trans('mautic.sms.sent'));
     if ($listCount) {
         /** @var \Mautic\SmsBundle\Entity\StatRepository $statRepo */
         $statRepo = $this->em->getRepository('MauticSmsBundle:Stat');
         foreach ($lists as $l) {
             $name = $l->getTitle();
             $sentCount = $statRepo->getSentCount($smsIds, $l->getId());
             $datasets[$combined][0] += $sentCount;
             $datasets[$name] = array();
             $datasets[$name] = array($sentCount);
             $datasets[$name]['datasetKey'] = $l->getId();
         }
     }
     if ($listCount === 1) {
         unset($datasets[$combined]);
     }
     $data = GraphHelper::prepareBarGraphData($labels, $datasets);
     return $data;
 }